In my previous post
How to accept multiple query parameters with different parameter name in one class
I learned about passing the query parameters, and I also achieved it But now the problem is I am in a swagger setup where I use codegen for generating API default code which provides me an interface using which I implement it into my controller layer and overrides those methods and add my logic
The problem is I have an internal api-doc file that generates a custom code, in that file how should I mention that I am using my own custom class for passing it to be used as a query parameter object? Currently, my api doc file looks like below. Problem with below file is I have to define each and every query parameter and as I learned in my previous stack article that we can wrap it into an class object. But my question here is how should I mention path to my custom class into this file.
/tasks:
get:
parameters:
- $ref: 'api-params.yaml#/name'
- $ref: 'api-params.yaml#/age'
- $ref: 'api-params.yaml#/credentials'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: 'api-resp.yaml#/someResponse'
"401":
description: "Unauthorized"
content: { }
"403":
description: "Forbidden"
content: { }
And also can we directly define a model using swagger? If yes how can we do that? I mean I am using custom models for referring them to be used as request body and I usually mention them like below, but my question is can we use similar behaviour for queryParams also
schema:
$ref: '#/components/schemas/RquestBodyPayload'
but is the similar this is also allowed for query parameters ?