Skip to content
\n

The result I want is to have productID and productName as parameters in the yml documentation.
\nSomething like :

\n
openapi: 3.0.1\ninfo:\n title: OpenAPI definition\n version: v0\nservers:\n- url: http://localhost:8080\n description: Generated server url\npaths:\n /product:\n   get:\n     tags:\n     - product-controller\n     operationId: getProductTOsByFilter\n     parameters:\n     - name: productID\n       in: query\n       required: false\n     - name: productName\n      in: query\n      required: false\n     responses:\n       \"200\":\n         description: OK\n         content:\n           '*/*':\n             schema:\n               type: array\n               items:\n                 $ref: \"#/components/schemas/ProductTO\"\ncomponents:\n schemas:\n   ProductTO:\n     type: object\n     properties:\n       productID:\n         type: string\n       productName:\n         type: string\n       weight:\n         type: number\n         format: float\n       description:\n         type: string
\n

Thank you everyone in advance

","upvoteCount":3,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"

I believe a possible approach could be to introduce a meta-annotation similar to the one introduced here, and then make it carry a number of annotations that describe the query parameters that you have (and you could probably make the annotation take an argument, so you could controller the required value for each annotation?).

\n

The annotation that I am thinking of would be:

\n
@Parameter(name = \"queryValue\", in = ParameterIn.QUERY, example = \"1\", schema = @Schema(type = \"number\"))
\n

from swagger annotations.

","upvoteCount":0,"url":"https://github.com/springdoc/springdoc-openapi/discussions/3029#discussioncomment-13596309"}}}

Add QueryString documentation when using TransferObject with @ModelAttribute as single argument #3029

Discussion options

You must be logged in to vote

I believe a possible approach could be to introduce a meta-annotation similar to the one introduced here, and then make it carry a number of annotations that describe the query parameters that you have (and you could probably make the annotation take an argument, so you could controller the required value for each annotation?).

The annotation that I am thinking of would be:

@Parameter(name = "queryValue", in = ParameterIn.QUERY, example = "1", schema = @Schema(type = "number"))

from swagger annotations.

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@angelomarzocchi
Comment options

@Mattias-Sehlstedt
Comment options

Answer selected by angelomarzocchi
@Mattias-Sehlstedt
Comment options

@angelomarzocchi
Comment options

@Mattias-Sehlstedt
Comment options

@angelomarzocchi
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants