Skip to content

[9.0-preview7] Response schema being returned as IResult #56975

Closed
@martincostello

Description

@martincostello

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Updating from version 9.0.0-preview.7.24372.9 to 9.0.0-preview.7.24373.9 of Microsoft.AspNetCore.OpenApi, [ProducesResponseType] seems to have stopped working and instead of the correct response type for an API endpoint, IResult is returned instead.

Here's the document:

{
  "openapi": "3.0.1",
  "info": {
    "title": "London Travel",
    "description": "London Travel is an Amazon Alexa skill for checking the status for travel in London.",
    "termsOfService": "https://londontravel.martincostello.com/terms-of-service/",
    "contact": {
      "name": "Martin Costello",
      "url": "https://github.com/martincostello/alexa-london-travel-site"
    },
    "license": {
      "name": "Apache 2.0",
      "url": "https://www.apache.org/licenses/LICENSE-2.0.html"
    },
    "version": ""
  },
  "servers": [
    {
      "url": "https://localhost"
    }
  ],
  "paths": {
    "/api/preferences": {
      "get": {
        "tags": [
          "LondonTravel.Site"
        ],
        "summary": "Gets a user's preferences.",
        "description": "Gets the preferences for a user associated with an access token.",
        "operationId": "GetApiPreferences",
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "description": "The authorization header.",
            "schema": {
              "type": "string",
              "nullable": true
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The preferences associated with the provided access token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IResult"
                }
              }
            }
          },
          "401": {
            "description": "A valid access token was not provided.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "statusCode": 401,
                  "message": "Unauthorized.",
                  "requestId": "0HKT0TM6UJASI",
                  "details": [
                    "Only the Bearer authorization scheme is supported."
                  ]
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ErrorResponse": {
        "required": [
          "statusCode",
          "message",
          "requestId",
          "details"
        ],
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "integer",
            "description": "The HTTP status code.",
            "format": "int32"
          },
          "message": {
            "type": "string",
            "description": "The error message."
          },
          "requestId": {
            "type": "string",
            "description": "The request Id."
          },
          "details": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The error details, if any."
          }
        },
        "description": "Represents an error from an API resource."
      },
      "IResult": {
        "type": "object"
      }
    },
    "securitySchemes": {
      "Bearer": {
        "type": "http",
        "description": "Access token authentication using a bearer token.",
        "scheme": "bearer",
        "bearerFormat": "Opaque token"
      }
    }
  },
  "security": [
    {
      "Bearer": [ ]
    }
  ],
  "tags": [
    {
      "name": "LondonTravel.Site"
    }
  ]
}

Expected Behavior

A schema for PreferencesResponse should be returned.

Steps To Reproduce

  1. Clone martincostello/alexa-london-travel-site@2a6df23
  2. Start the app
  3. Browser the OpenAPI document returned by /openapi/api.json

Exceptions (if any)

No response

.NET Version

9.0.100-preview.7.24374.2

Anything else?

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions