Answer the question
In order to leave comments, you need to log in
How to describe in the OpenApi specification a DTO field, which is an object that lies in another package (not in a DTO)?
Good afternoon
There is a project without an OpenApi / Swagger specification with the described Model, Dto, etc. classes in the code. I
plan to describe the specification so that DTO classes are generated from it.
I describe DTO classes with fields in Components.
When you need to describe a field that is an object and lies in the same DTO package, then I write like this:
UserDto
type: object
properties:
status:
$ref: '#/components/schemas/StatusDTO'
(and below in the same spec I have described StatusDTO)
And how to make a link (and is it possible) if one of the UserDto fields is not a DTO object, but an object from the model? For example, just "Status" and lies in another package. models.
I tried to find a solution in the OpenApi documentation, but something did not work out. Found only links to other .yaml files.
OpenApi version: 3.0.1
Answer the question
In order to leave comments, you need to log in
When you need to describe a field, <...>, then I write like this:
schemas:
UserDto:
type: object
properties:
status:
$ref: '#/components/schemas/StatusModel'
StatusModel: ~
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question