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

Content definition in @ApiResponse remove schema generated based on the returned value #2663

Closed
MarianaSequeira opened this issue Jul 30, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@MarianaSequeira
Copy link

When defining content in the @ApiResponse the default schema is no longer defined in the OpenApi spec.

If we annotate our endpoint using the following:

@ApiResponse(responseCode = "200", description = "OK")
Map<Class1, Map<Class2, Set<String>>> get();

We have the following schema being generated:

"responses": {
  "200": {
    "description": "OK",
    "content": {
      "*/*": {
        "schema": {
          "type": "object",
          "additionalProperties": {
            "type": "object",
            "additionalProperties": {
              "uniqueItems": true,
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
}

However, we automatically lose this valuable information when defining content (even if we use useReturnTypeSchema).
For example, for the following code:

@ApiResponse(
        useReturnTypeSchema = true,
        responseCode = "200",
        description = "OK",
        content = {
                @Content(
                        mediaType = "*/*",
                        examples =
                            @ExampleObject(
                                    name = "success",
                                    value ="..."))
        }
)
Map<Class1, Map<Class2, Set<String>>> get();

We get the following:

"responses": {
  "200": {
    "description": "OK",
    "content": {
      "*/*": {
        "examples": {
          "success": {
            "description": "success",
            "value": "..."
          }
        }
      }
    }
  }
}

This hinders the process of generating concise and enriched documentation. Besides, I could not find in the documentation any reference saying that if content is defined the default schema is not used. This is particularly relevant as it is not possible to achieve this schema description using annotations in the code.

@bnasslahsen bnasslahsen added the enhancement New feature or request label Sep 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants