Skip to content

ApiDescriptionProvider does not return SupportedResponseTypes when using controllers with Results<T> #56763

Closed
@jgarciadelanoceda

Description

@jgarciadelanoceda

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I have been studyng the issue domaindrivendev/Swashbuckle.AspNetCore#2595 and have been playing with the new package Microsoft.AspNetCore.OpenApi, and when the response of a Controller is a Results I do not see the response in either SwashBuckle or AspNetCore.OpenApi.

I have just created a repro: https://github.com/jgarciadelanoceda/OpenApiResults where you can see that the OpenApi generated is missing the response for the Controller.

This is the generated schema:

"/api/Enum": {
      "get": {
        "tags": [
          "Enum"
        ],
        "parameters": [
          {
            "name": "logLevel",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 4,
              "nullable": true
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "x-aspnetcore-id": "5e99fe30-6a3d-4302-8ddf-c3098e430266"
      }
    }

Please note that there is no reference to the enum neither in parameters or in the responseType.

For the response, I guess that the thing that is missing is the SupportedResponseTypes

Expected Behavior

I expect the response of the OpenApi generated schema to have the enum reference:

 "/api/Enum": {
      "get": {
        "tags": [
          "Enum"
        ],
        "parameters": [
          {
            "name": "logLevel",
            "in": "query",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/LogLevel"
                }
              ],
              "default": 4
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
 "content": {
              "text/plain; v=1.0": {
                "schema": {
                  "$ref": "#/components/schemas/LogLevel"
                }
              },
              "application/json; v=1.0": {
                "schema": {
                  "$ref": "#/components/schemas/LogLevel"
                }
              },
              "text/json; v=1.0": {
                "schema": {
                  "$ref": "#/components/schemas/LogLevel"
                }
              }
            }
          }
        }
      }
    }

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

Net9

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    old-area-web-frameworks-do-not-use*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions