-
Notifications
You must be signed in to change notification settings - Fork 10k
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
Incorrect OpenAPI schema generated for implicit services/special types/parseables #44677
Comments
Great sample app! Thanks for putting it together.
It looks like the
I suspect the same thing happening for services is happening here. We need to update the pseudo-model binding logic in the ApiExplorer to match the new behavior in MVC.
We're using Swahsbuckle's schema generator here (see this PR). It looks like the schema generator does not support generating schemes for those two types yet... |
@martincostello implicit service resolution, as all other implicit source resolution, are enable by default for API Controllers only, so you need to add the |
A type with |
Confirmed that adding |
Do not generate schema models for `Stream` and `PipeReader`. See dotnet/aspnetcore#44677 (comment).
@captainsafia Do you think this is the right fix for item 3, or have I got the best representation for the data here completely wrong and it just "fixes it" by accident? Testing locally, |
@brunolins16 I had a quick look at the code. I didn't fully dig through and understand it all, but I wondered if this line needs changing to use
- UnderlyingOrModelType = Nullable.GetUnderlyingType(ModelType) ?? ModelType;
+ UnderlyingOrModelType = IsParseableType ? typeof(string) : Nullable.GetUnderlyingType(ModelType) ?? ModelType; |
I think is not possible to simply change it because it might affect the binding logic. However we might be able to apply the same idea in the API Explorer but we will need to think how can we differentiate from primitives ( I need to check what we are doing for Minimal Endpoints. BTW: Types with |
@martincostello Maybe we can do the same as here aspnetcore/src/Mvc/Mvc.ApiExplorer/src/EndpointMetadataApiDescriptionProvider.cs Lines 291 to 292 in dcbfb82
I will do some experiments and create a PR if it works. Thanks for reporting this bug. |
I give it a try but, if I got it correctly, |
I think that should be sufficient given the version of OpenAPI schema that Swashbuckle is currently targeting. I went down a bit of a rabbit hole trying to figure out what the best type/format to use is given the different OAS versions but this seems to be appropriate for v3.0. |
Great, thanks for looking @captainsafia - I'll open a PR against Swashbuckle with that change shortly 👍 |
Thanks for contacting us. We're moving this issue to the |
Do not generate schema models for `Stream` and `PipeReader`. See dotnet/aspnetcore#44677 (comment).
Do not generate schema models for `Stream` and `PipeReader`. See dotnet/aspnetcore#44677 (comment).
Is there an existing issue for this?
Describe the bug
I'm working on a talk I'll be giving soon on new features in ASP.NET Core 7 and Minimal APIs, and in the process of updating my sample application for RC2 I've noticed a number of issues with the OpenAPI schema generated for various endpoints in the sample.
Stream
andPipeReader
to consume the request body shows bothStream
andPipeReader
in the schema.Expected Behavior
MyService
is not shown as an endpoint parameter and is not included in the OpenAPI schemas.name
parameter is shown as a simple string andName
is not included in the OpenAPI schemas.Stream
andPipeReader
are not included in the OpenAPI schemas.Steps To Reproduce
https://localhost:5001/swagger-ui/index.html
.Exceptions (if any)
None.
.NET Version
7.0.100-rc.2.22477.23
Anything else?
The text was updated successfully, but these errors were encountered: