-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OpenApi inline enum for query parameters #57979
Comments
Just spotted this one myself with version With martincostello/openapi-extensions@5742a21 I get an empty enum for "CarType": {
"type": "integer",
"description": "The type of the car."
} |
The behavior that I find surprising here is that the schemas generated for the response and the query parameter are different. The schema generated by the query parameter uses a Upon further debugging, the issue seemed to only manifest for endpoints that used controller actions (as opposed to minimal APIs) which is particularly strange given that the schema generation logic is shared between the two. Some further debugging reveals that this might be an issue with the ApiExplorer layer for MVC because the Based on the logic here. My suspicion gravitated towards the recent changes we made to ModelMetadata to support native AoT since the referenced method interacts with the It seems like the actual root cause is some code that we added in 46b5580 that set the parameter type of simple types (including those that can be parsed from an enum) to Anyhow, I've figured out a bug fix for this that I hope to include in .NET 9 but figured I'd monologue a bit about the root case here for posterities sake. |
* Fix JsonUnmappedMemberHandling attribute handling to close #57981 * Fix enum handling for MVC actions to close #57979 * Fix self-referential schema handling to close #58006 * Fix concurrent request handling for OpenAPI documents (#57972) * fix: Allow concurrent requests * test: Update test * test: Use Parallel.ForEachAsync * feat: Use valueFactory overload * feat: Pass valueFactory directly * Harden self-referencing schema ID check --------- Co-authored-by: Justin Lampe <xC0dex@users.noreply.github.com>
* Fix JsonUnmappedMemberHandling attribute handling to close #57981 * Fix enum handling for MVC actions to close #57979 * Fix self-referential schema handling to close #58006 * Fix concurrent request handling for OpenAPI documents (#57972) * fix: Allow concurrent requests * test: Update test * test: Use Parallel.ForEachAsync * feat: Use valueFactory overload * feat: Pass valueFactory directly * Harden self-referencing schema ID check --------- Co-authored-by: Justin Lampe <xC0dex@users.noreply.github.com>
@dnv-kimbell The fix for this has landed in nightly package version You'll need to use the following
And make sure that you have a reference to the nightly dotnet9 feed in your
Can you let me know if that works for you? |
When I try that package, I get a reference to the enum from the query section, both with and without flags, so it seems to be working as expected. "parameters": [
{
"name": "e",
"in": "query",
"schema": {
"$ref": "#/components/schemas/EnumWithFlags"
}
}
],
"parameters": [
{
"name": "e",
"in": "query",
"schema": {
"$ref": "#/components/schemas/EnumWithNoFlags"
}
}
], |
@dnv-kimbell Great! Thanks for verifying. Closing this bug as fixed. |
… (#58096) * Fix JsonUnmappedMemberHandling attribute handling to close #57981 * Fix enum handling for MVC actions to close #57979 * Fix self-referential schema handling to close #58006 * Fix concurrent request handling for OpenAPI documents (#57972) * fix: Allow concurrent requests * test: Update test * test: Use Parallel.ForEachAsync * feat: Use valueFactory overload * feat: Pass valueFactory directly * Harden self-referencing schema ID check --------- Co-authored-by: Justin Lampe <xC0dex@users.noreply.github.com>
Is there an existing issue for this?
Describe the bug
I have an operation with that takes in an enum as query string parameter, and returns it back in the response.
In the parameter section, the enum is just defined as string with no information about what valid values are
In the response the enum is referenced and it's possible to figure out valid values
Expected Behavior
The query parameter should use a reference to the enum schema.
Steps To Reproduce
https://github.com/dnv-kimbell/openapi-inlineschema
Exceptions (if any)
No response
.NET Version
9.0 RC1
Anything else?
No response
The text was updated successfully, but these errors were encountered: