Should path parameters be implicitly required in the parameterSchema JsonSchema? #80
ouvreboite
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
(I hope I'm following the right process for this kind of discussion, don't hesitate to redirect me if needed 🙂)
The problem
Looking at the various examples, I have the feeling that having
parameterSchema
being a full JsonSchema will lead to either inconsistent definition or too much verbosity.Extract from the petstore example
For example,
petId
is not marked as required, while it is (it's a path parameter, not an optional query parameter). This gives us two options:parameterSchema
is supposed to be a 'raw' JsonSchema, but does not really behave like one. Furthermore, when handling both path params and required query params, should only the required query params be marked as required? Or also the path params?🗎 Implicit required confusion example:
🗎 Explicit required verbosity example:
Proposal
If we want to improve readability and editability, I think the path parameter must be implicitly required, but we could go a bit farther. For example, it's could also be implicit that parameterSchema is
type: object
. Factoring thetype: object
out, only theproperties
andrequired
part of the JSonSchema remains. And those could be moved directly on the path object.So, instead of expecting a full JSONSchema, we could have the path (and request) object expose both
path.parameters
(~= JsonSchema's object.properties) andpath.requiredQueryParameters
(~= JsonSchema's object.required), with path parameters being implicitly required.This would make the syntax more compact, while avoiding confusion when mixing path parameters and required query parameters. But we would still leverage JsonSchema's property syntax.
🗎 A petstore-like example
🗎Applying it to the parameterSchema example
Beta Was this translation helpful? Give feedback.
All reactions