[openapi-jsonschema-parameters] No properties copied over for parameters of type object
See original GitHub issueopenapi-jsonschema-parameters
strips the properties
from the schema for things like query and path params.
I’m mostly interested in the former, as this is causing issues in my particular use case of validating the pagination query parameters for a JSON:API request (spec).
Please find the below snippet from our OAI3 schema for the page
query parameter:
components:
parameters:
PageQueryParam:
name: page
in: query
schema:
description: |
Although JSON:API doesn't enforce any specific pagination strategy, it does reserve the `page` query parameter
and suggests using an object with fields corresponding to parameters relating to the selected pagination strategy.
type: object
externalDocs:
description: JSON:API Pagination
url: https://jsonapi.org/format/1.0/#auto-id--pagination
properties:
offset:
type: integer
limit:
type: integer
maximum: 100 # TODO: magic number
At the moment ajv
in the request validator is not given the properties
of the object, so it can only validate the type of the page
query param, which in this case is object
. This results in incorrect values for page[offset]
or page[limit]
passing the validation done by openapi-request-validator
.
I will issue a PR later today once I have the chance, but my sort-of quickfix solution is to add See edit below.properties
to the VALIDATION_KEYWORDS
array.
Please share your thoughts.
EDIT:
Okay, yeah, just adding properties
into the VALIDATION_KEYWORDS
won’t suffice as it will just copy the properties without converting them to JSON Schema. Looking further into it.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Sorry for the long wait. I think the best advice for anyone using this project would be to just add middleware for validating object-type parameters by themselves, just to keep this project simple.
Hi again, I’ve been looking at a few things to make sure I don’t break anything, and I’ve noticed that the OAI2 spec doesn’t allow object-valued parameters in non-body parameters (link).
I’m gonna have to ponder on this some more, as I was approaching this from the perspective of OAI3, which is my use case.