-
Notifications
You must be signed in to change notification settings - Fork 101
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: Support for OpenAPI defined formats #75
Comments
Yes, string is easy, and the linked tests deal with strings. But distinguishing between If I'm missing something, could you elaborate how the mentioned Any thoughts on the main topic here, i.e. the OpenAPI formats? |
i am not sure exact behaviour in that example. possibly if you want to check if the value is integer, you can see how it is done here also json spec validates regarding the openapi formats, you can use |
Note that for the time being, these formats apply not only to integer types, but numbers too. https://github.com/OAI/OpenAPI-Specification/blob/3.1.0/versions/3.1.0.md#dataTypes Refs santhosh-tekuri#75
Unfortunately Anyway re those int checks, they're easy, too. But they won't work in preventing formats that are defined for |
Note that for the time being, these formats apply not only to integer types, but numbers too. https://github.com/OAI/OpenAPI-Specification/blob/3.1.0/versions/3.1.0.md#dataTypes Refs santhosh-tekuri#75
Note that for the time being, these formats apply not only to integer types, but numbers too. https://github.com/OAI/OpenAPI-Specification/blob/3.1.0/versions/3.1.0.md#dataTypes Refs santhosh-tekuri#75
i am not sure whether you should provide openapi formats by default. if user is trying to validate openapi file, he will use openapi library for that. he/she never uses this library directly. that openapi library internally will use this library for validation. in such case it is better to let the openapi library provide implementation for openapi specific format. will hold this issue/pull request in case i change my mind later... |
I submitted this for a reason ;). I'm using this particular library with OpenAPI, because no OpenAPI lib that I've found comes close to what I like to see. It's been a while, but in particular IIRC there wasn't one that would support OpenAPI 3.1. Another use case is that OA 3.1 supports actual JSON schema, and things modeled in the schemas can be used with other things than OA, such as message queue payloads, etc. It's not at all sure if an OA lib would be sanely applicable to such use cases, whereas this one is. |
I have played with openapi v3.1 and created a lib that uses this library for validation: https://github.com/sv-tools/openapi |
OpenAPI defines some additional formats over the JSON schema validation spec:
https://github.com/OAI/OpenAPI-Specification/blob/3.1.0/versions/3.1.0.md#dataTypes
Would there be interest in adding support for those
int32
/int64
/float
/double
formats ones built in in this project? I have some half done implementations that I could complete and submit.Aside, implementing those exposes a small problem with the way formats are mapped currently: for example the
int32
andint64
formats cannot be restricted to apply only tointeger
types. The format validator function cannot decide that based on the value type alone, thus those functions will be available and executed fornumber
types as well; the type of the received value will be e.g.json.Number
orfloat64
for both, and it might be valid for both as far as the type goes. Not that big of a problem, avoidable by simply not writing schemas that would use these formats fornumber
s, but I thought I'd mention it. Changing the format validator registration to also consider the type instead of just the format name would be a fix, if deemed worth fixing.The text was updated successfully, but these errors were encountered: