OpenApi 3 specify all Query Parameters using a single Schema ref with Marshmallow Plugin
Hi,
I have a python project and I am using Marshmallow to define my schemas for input, output and query parameters.
I am now trying to create my OpenAPI 3 docs using apispec library and I'm running into an issue with rendering my query parameters.
I have this snippet in my doc declaration of my route where ListQueryParameters contains all my query parameters (like page, sortby, etc..) It fails to render unless I add `name`.
But according to https://apispec.readthedocs.io/en/latest/_modules/apispec/ext/marshmallow/schema_resolver.html#SchemaResolver.resolve_parameters and it's docs https://apispec.readthedocs.io/en/latest/api_ext.html#apispec.ext.marshmallow.schema_resolver.SchemaResolver.resolve_parameters, it should work.
parameters:
- customerId
- in: query
name: queryParams
schema: $ref: '#/components/schemas/ListQueryParameters'
In the final generation of my openapi spec documentation the query param section it shows queryParams as a JSON object for input which has all my listed parameters.
However I want the final docs generated to be a name value pair of these properties, not a nested object.
I can manually specify these as a workaround, but don't want to maintain this list of properties as some apis have 50+ query parameters
parameters:
- customerId
- in: query
name: sortby
description: Sort by description
- in: query
name: page
description: Current Page to view
schema:
type: int
...
Is there an easy way to resolve accomplish this without doing my workaround?
Thanks,
Art
It was an issue on my side as I did not need to specify the `ref` part pointing to my schema.
Details can be found here:
https://github.com/marshmallow-code/apispec/issues/732