Skip to content
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

Fix missing exception response types in OpenAPI spec #2577

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mschout
Copy link

@mschout mschout commented Apr 18, 2024

Since e893628, some error response types referenced by the schema in $ref's were missing from the spec.

For example, we have a custom error response type that gets returned via @ControllerAdvice when we throw a specific exception type. In v2.3.0, these were correctly included in the OpenAPI spec. Starting in v2.4.0 these were missing, creating an invalid schema.

e.g.:

"400": {
            "description": "Bad Request",
            "content": {
              "*/*": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/BadRequestExceptionResponse"
                    },
                    {
                      "$ref": "#/components/schemas/ValidationErrorResponse"
                    }
                  ]
                }
              }
            }

and then later down, we should have BadRequestExceptionResponse in the spec under .compoents.schemas like this:

"BadRequestExceptionResponse": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          }
        }
      },

Quick git bisect revealed that this broke in e893628. I don't fully know the logic behind that commit, but the attached pull request gets the missing items back in the schema for us by changing how the ObjectMapper is constructed back to the way it was before e893628

Since e893628, some error response
types referenced by the schema in `$ref`'s were missing from the
spec.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant