Add QueryString documentation when using TransferObject with @ModelAttribute as single argument #3029
-
| I'd like to add OpenAPI documentation to my project but I have the following problem : openapi: 3.0.1
info:
 title: OpenAPI definition
 version: v0
servers:
- url: http://localhost:8080
 description: Generated server url
paths:
 /product:
   get:
     tags:
     - product-controller
     operationId: getProductTOsByFilter
     parameters:
     - name: filter
       in: query
       required: true
       schema:
         $ref: "#/components/schemas/ProductTO"
     responses:
       "200":
         description: OK
         content:
           '*/*':
             schema:
               type: array
               items:
                 $ref: "#/components/schemas/ProductTO"
components:
 schemas:
   ProductTO:
     type: object
     properties:
       productID:
         type: string
       productName:
         type: string
       weight:
         type: number
         format: float
       description:
         type: stringThe result I want is to have productID and productName as parameters in the yml documentation. openapi: 3.0.1
info:
 title: OpenAPI definition
 version: v0
servers:
- url: http://localhost:8080
 description: Generated server url
paths:
 /product:
   get:
     tags:
     - product-controller
     operationId: getProductTOsByFilter
     parameters:
     - name: productID
       in: query
       required: false
     - name: productName
      in: query
      required: false
     responses:
       "200":
         description: OK
         content:
           '*/*':
             schema:
               type: array
               items:
                 $ref: "#/components/schemas/ProductTO"
components:
 schemas:
   ProductTO:
     type: object
     properties:
       productID:
         type: string
       productName:
         type: string
       weight:
         type: number
         format: float
       description:
         type: stringThank you everyone in advance | 
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
| It seems to have been discussed before and then it was a no #119 (and a second time more recently #2439). 
 Could we elaborate on this reasoning? Personally I would like the api-object itself to describe what expectations it has on data (i.e., whether it is required or not), so I would most likely create several different ProductXTO to describe the different permutations of required field combinations that can exists (this is of course not viable if  | 
Beta Was this translation helpful? Give feedback.
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
requiredvalue for each annotation?).The annotation that I am thinking of would be:
from swagger annotations.