-
Notifications
You must be signed in to change notification settings - Fork 6
Add support for OpenAPI 3.0 parameter object #23
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
Comments
Thank you, this is a very good overview and I agree with everything! Here's some additional throughts: 2. if the schema already has 9. Yes, let's be explicit and go with |
Good point on number 2! Agrees with your comment on number 9 as well. Would you like me to work on a PR for this? |
Please be free to work on a PR, that would be very helpful! I modularized the codebase a bit. There's |
Done in #25 |
Uh oh!
There was an error while loading. Please reload this page.
Continuation of #9
We should be able to convert an OpenAPI 3.0 Parameter object into a JSON schema v4.
Several issues:
parameter.content
. One possible solution is to return a{ "MIME": jsonSchema, ... }
object. Problem is this means this library would return two different types of return values (a MIME map or a simple JSON schema). This would require users to guess which type has been returned. Possible solutions (I personally prefer c) ):a) always return a MIME map. I.e. instead of returning a simple JSON schema, return
{ "*/*": jsonSchema }
b) add a property like
{ "isMimeMap": true, ... }
when a MIME map was returnedc) make sure
$schema
is always included in returned JSON schemas, in which case users can use that to determine if it's a JSON schema or a MIME mapd) return
{ anyOf: [{ ...jsonSchema, "x-mime": "MIME" }, ...] }
JSON schemaparameter.description
tojsonSchema.description
? I suggest we do.parameter.required
has two issues. First it is aboolean
not an array like in JSON schema. Second it could not be converted to an array without returning the parameters object instead of a single parameter. I suggest we removeparameter.required
.parameter.allowEmptyValue
. See [Feature] Add support forallowEmptyValue
#8. The property is very confusing to even the OpenAPI designers themselves. It's unclear what it actually does. It will be deprecated in 3.0.2 and eventually removed. I suggest we removeparameter.allowEmptyValue
parameter.name|in|deprecated
do not seem to have any corresponding JSON schema keywords, so I suggest we remove them.parameter.example|examples
andparameter.content.MIME.example|examples
could be converted toexamples
. But that keyword is JSON schema v6, so I suggest we remove those properties since we only support JSON schema v4.parameter.allowReserved|style|explode
andparameter.content.MIME.encoding
: those properties are about how to parse the parameter, not about validation, so I suggest we remove them.parameter.schema
orparameter.content.MIME.schema
Parameter Object
and not aSchema Object
? We could check for required propertiesname
andin
. This would work but might not be extensible if we want to add other definitions, or for future OpenAPI versions. Another solution (which I would suggest) would be to export another function, e.g.require("open-api-schema-to-json-schema").fromParameter()
andrequire("open-api-schema-to-json-schema").fromSchema()
This would result in the following:
parameter.schema
if availableparameter.content
is used, we return a{ "MIME": jsonSchema }
map. Let's double check that$schema
is always available.parameter.description
. Everything else we remove.The text was updated successfully, but these errors were encountered: