Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] support content as alternative to schema for parameters #204

Open
tglander opened this issue Jun 26, 2023 · 0 comments
Open

Comments

@tglander
Copy link

tglander commented Jun 26, 2023

Usecase

I would like to document a query parameter that is given as a JSON structure in order to define complex filter options (e.g. attribute + filter operation in, not-in, eq, lt, gt,...). According to openapi documentation, this should be possible using content specs instead of schema https://swagger.io/docs/specification/describing-parameters/#schema-vs-content

an example for a filter parameter with a nested object

        - in: query
          name: filter
          content:
            application/json:
              schema:
                type: object
                properties:
                  captureId:
                    type: object
                    properties:
                      IN:
                        type: array
                        items:
                          type: string
                      NOTIN:
                        type: array
                        items:
                          type: string

Envisioned solution

As a solution, I think that the Parameter constructor function should also allow to provide the option to provide the content object. Looking at the current code, it might work to accept the MediaType, which is currently only used to construct body and response components.

Workarounds I tried:

  1. I tried to work around this using kwargs of Parameter constructor or other options using a dict, but at some point the SpecificationBuilder requires presence of schema and forces it to be string, so in the end it does not work
  2. I also tried to simplify the nested object and use deepObject style, but this does not work because sanic-ext cannot understand it. E.g. parameters given like ?captureId[IN]=1,2,3&captureId[NOTIN]=5 are not merged together into an object like captureId={IN:[1,2,3], NOTIN=[5]}
@tglander tglander changed the title [Feature Request] [Feature Request] support content as alternative to schema for parameters Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant