Skip to content

Incorrect OpenAPI schema generated for implicit services/special types/parseables #44677

@martincostello

Description

@martincostello

Is there an existing issue for this?

  • 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 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 for an MVC controller renders the service as an object in the OpenAPI schema and as a query string parameter.

image

image

  1. Using TryParse() support for parameters for an MVC controller has a similar issue, and renders the query string parameter as an object mirroring the C# model, rather than as a string.

image

image

  1. Using the support for Stream and PipeReader to consume the request body shows both Stream and PipeReader in the schema.

image

image

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 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?

> 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etc

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions