-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Add support for generating OpenAPI responses #55020
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
Conversation
response.Content[contentType] = new OpenApiMediaType(); | ||
} | ||
|
||
// MVC's `ProducesAttribute` doesn't implement the produces metadata that the ApiExplorer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we change that? The less MVC we reference, the better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we discussed this in the past when we originally introduced the ProducesResponseTypeMetadata
type. I think the conclusion at the time was to create new metadata/attributes for these annotations that was shared between MVC/minimal instead of recycling the existing ones.
Because this implementation needs to work for both controller-based and minimal APIs, we're not going to be able to get away with having less MVC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have questions, but I'm pretty sure they're about OpenApi and not your code.
src/OpenApi/sample/Sample.csproj
Outdated
@@ -18,4 +18,8 @@ | |||
<Reference Include="Microsoft.AspNetCore.Mvc" /> | |||
</ItemGroup> | |||
|
|||
<ItemGroup> | |||
<ProjectReference Include="../test/Microsoft.AspNetCore.OpenApi.Tests.csproj" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would a sample reference the tests? We don't want customers to do that, do we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, it's for the "shared" TODO types. I think I'd probably redeclare them to keep the sample self-contained.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized that I can use a Compile
-include to do this. 🤦🏽♀️ 😅
Edit: I realize this doesn't make the sample very self-contained but the samples in the repo don't lend themselves nicely to being pulled out, especially because they rely on the special reference resolution setup that we have in the repo.
71e22c3
to
01656b4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much clearer. Thanks!
Co-authored-by: Martin Costello <[email protected]> Co-authored-by: Rick Anderson <[email protected]> This PR adds support for OpenAPI document generation, sans schema generation to Microsoft.AspNetCore.OpenApi. Relevant changes are available in individual PRs: - Add entry-point APIs for OpenAPI support (#54789) - Support resolving OpenApiPaths entries from document (#54847) - Support generating OpenAPI operation and associated fields (#54903) - Add APIs for OpenAPI document transformers (#54935) - Add support for generating OpenAPI parameters (#55041) - Add support for generating OpenAPI responses (#55020) - Add support for generating OpenAPI request bodies (#55040)
Support generating OpenAPI response for a given operation.
Current results for GenerationBenchmark: