Incorrect OpenAPI schema generated for implicit services/special types/parseables
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### 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](https://github.com/martincostello/aspnet-core-7-samples) for RC2 I've noticed a number of issues with the OpenAPI schema generated for various endpoints in the sample.
1. Using [implicit service resolution](https://devblogs.microsoft.com/dotnet/asp-net-core-updates-in-dotnet-7-preview-2/#infer-api-controller-action-parameters-that-come-from-services) for an [MVC controller](https://github.com/martincostello/aspnet-core-7-samples/blob/f0d3dccb4592afdd0dd49e984f3ef836158e1b69/src/TodoApp/SampleController.cs#L11-L16) renders the service as an object in the OpenAPI schema and as a query string parameter.


2. Using [TryParse() support](https://devblogs.microsoft.com/dotnet/asp-net-core-updates-in-dotnet-7-preview-3/#bind-using-tryparse-in-mvc-and-api-controllers) for parameters for an [MVC controller](https://github.com/martincostello/aspnet-core-7-samples/blob/f0d3dccb4592afdd0dd49e984f3ef836158e1b69/src/TodoApp/SampleController.cs#L21-L25) has a similar issue, and renders the query string parameter as an object mirroring the C# model, rather than as a string.


3. Using the [support for `Stream` and `PipeReader`](https://devblogs.microsoft.com/dotnet/asp-net-core-updates-in-net-7-preview-1/#bind-the-request-body-as-a-stream-or-pipereader) to consume the request body shows both [`Stream`](https://github.com/martincostello/aspnet-core-7-samples/blob/f0d3dccb4592afdd0dd49e984f3ef836158e1b69/src/TodoApp/SampleEndpoints.cs#L171-L192) and [`PipeReader`](https://github.com/martincostello/aspnet-core-7-samples/blob/f0d3dccb4592afdd0dd49e984f3ef836158e1b69/src/TodoApp/SampleEndpoints.cs#L194-L201) in the schema.


### Expected Behavior
1. `MyService` is not shown as an endpoint parameter and is not included in the OpenAPI schemas.
2. The `name` parameter is shown as a simple string and `Name` is not included in the OpenAPI schemas.
3. `Stream` and `PipeReader` are not included in the OpenAPI schemas.
### Steps To Reproduce
1. Clone the [martincostello/aspnet-core-7-samples](https://github.com/martincostello/aspnet-core-7-samples) repository.
2. Build and run the application.
3. View the rendered OpenAPI schema with Swagger UI at `https://localhost:5001/swagger-ui/index.html`.
### Exceptions (if any)
None.
### .NET Version
7.0.100-rc.2.22477.23
### Anything else?
```sh
> dotnet --info
.NET SDK:
Version: 7.0.100-rc.2.22477.23
Commit: 0a5360315a
Runtime Environment:
OS Name: Windows
OS Version: 10.0.22000
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\7.0.100-rc.2.22477.23\
Host:
Version: 7.0.0-rc.2.22472.3
Architecture: x64
Commit: 550605cc93
```
Contributor guide
Assessment
This issue has not been assessed yet.