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

Inline response objects #165

Closed
rockxwre opened this issue Nov 20, 2019 · 2 comments
Closed

Inline response objects #165

rockxwre opened this issue Nov 20, 2019 · 2 comments

Comments

@rockxwre
Copy link

I am not sure if this question belongs here. But I will give it a try anyway.
I am using springdoc-openapi to generate an OAS3 yaml documentation based on my Spring controller/models.
What I want to achieve is to have an inline operation response. Something like this:

paths:
  /myoperation:
    get:
      ...
      responses:
        '200':
          content:
            application/json:
              schema:
                required:
                  - count
                  - results
                type: object
                properties:
                  count:
                    type: integer
                  results:
                    type: array
		    ...

The annotations of the operation method in the controller class looks like this:

@ApiResponse(responseCode = "200",
             description = "OK",
             content = @Content(mediaType = "application/json", schema = @Schema(implementation = MyResponseDTO.class, requiredProperties = { "count", "results"} ))

and MyResponseDTO:

public class MyResponseDTO {

    @Schema(required = true, description = "")
    private long count;

    @ArraySchema(schema = @Schema(implementation = MyModel.class))
    private List<DTO> results;

    ... getters/setters

}

This results in a schema with:

...
      responses:
        200:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MyResponseDTO'

...
components:
    MyResponseDTO:
      required:
      - count
      type: object
      properties:
        count:
          type: integer
          format: int64
        results:
          type: array
          items:
            $ref: '#/components/schemas/MyModel'

The response content is a reference instead of an inline object. Is there a way I can annotate the response/schema so that it will appear inline in the documentation?

@springdoc
Copy link
Collaborator

Hi,

We don't have any special feature related to inline object. We just rely on the official libraries.
You can ask your question, on the official swagger-core github:

@rockxwre
Copy link
Author

Thank you for your reply.
I have asked the question again here.

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

No branches or pull requests

1 participant