Fix OpenAPI property-level [JsonConverter] on [AsParameters] enum ignored with request body - #69241
Open
fahmymohammed wants to merge 1 commit into
Conversation
fahmymohammed
requested review from
a team,
Youssef1313,
cincuranet,
davpetr and
rokonec
as code owners
September 11, 2026 16:19
Contributor
|
Thanks for your PR, @fahmymohammed. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
Author
|
@dotnet-policy-service agree |
fahmymohammed
force-pushed
the
fix/openapi-asparameters-property-jsonconverter-69156
branch
from
September 11, 2026 20:03
e42fe3f to
d9242dd
Compare
…ored with request body Fixes dotnet#69156 When an [AsParameters] DTO had an enum property annotated with a property-level [JsonConverter(typeof(JsonStringEnumConverter))], the generated schema emitted "type": "integer" with no enum values whenever the endpoint also had a request body parameter. Enum parameters are generated from the bare type, which carries no property-level converter context, so the enum was registered as an integer component during parameter processing before the converter was ever seen. Detect property-level string enum converters in ApplyParameterInfo and drop the integer type keyword so the existing non-body enum handling supplies the string member names. Covers the non-generic, generic and derived JsonStringEnumConverter forms across query, header, route and form binding sources, and leaves converters that do not serialize enums as strings untouched.
fahmymohammed
force-pushed
the
fix/openapi-asparameters-property-jsonconverter-69156
branch
from
September 11, 2026 21:57
d9242dd to
9532b1b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #69156
[AsParameters]DTO has an enum property with a property-level[JsonConverter(typeof(JsonStringEnumConverter))], the generated schema emits{ "type": "integer" }instead of string enum values — but only when the endpoint also has a request body parameter.CreateSchema(Type)generates schemas for bare types without property-level converter context. When the response type doesn't reference the enum, it is first registered as an integer component during parameter processing — before the property-level converter is seen.JsonStringEnumConverterattributes inApplyParameterInfoand inject string enum values before the schema is componentized.Test plan
GetOpenApiParameters_HandlesPropertyLevelJsonStringEnumConverterWithRequestBody— the exact bug scenario (enum + body param)GetOpenApiParameters_HandlesPropertyLevelJsonStringEnumConverterWithoutRequestBody— confirms the already-working path stays correct