-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
Keep primitive types within JSON schema draft specs #340
Comments
Not sure I follow you here, @tlivings. |
and then from swagger
but
File, is not a primitive. It can not be validated standalone as a primitive because:
No JSON schema parser will support this, and as a result additional custom validation must be performed at a framework level to support swagger. Since this is the case, then there is little need to introduce a new "primitive" at all. |
Follow up: |
Another idea would be to use the hyper schema extensions for JSON schema. Example:
|
@tlivings Swagger-Tools goes beyond JSON Schema to validate things like this. If you're validating Swagger 2.0 specs in JavaScript I recommend it instead of pure JSON Schema validation. I understand your point about primitives but for 2.0 it's not going to change. |
Those are interesting tools, but Swagger is a specification, and that module is from a vendor, and is framework specific (example: connect/express middleware). In addition, I doubt the schema validation is as fast as some of the latest validators out there such as Swagger, afaik, wasn't designed to be a specification for apigee tools or A specification that is using JSON schema should follow JSON schema standards, not introduce implementation specifics that do not work with standards. |
@tlivings Swagger Tools is not vendor specific and it's MIT licensed. No reason to worry about Apigee paying it's maintainers do the work. Swagger offers a schema that tries to cover most of the spec. Note that schema is not the spec. There are some specifications in Swagger that is impossible to enforce via JSON Schema. For example "Each operation should have only one parameter of type body" and many more |
The issue isn't regarding Apigee maintaining the tool (wasn't implying that), and nor is it regarding general specifications of the swagger schema. The issue is that swagger claims to be JSON schema, and it is not. It adds a new primitive type, that is not a primitive. This requires every single consumer of the specification (i.e. anyone writing a framework or library) to provide the special edge case validation themselves. If it's going to be JSON schema, it should be standard JSON schema for the reasons outlined here and above. The specification can continue to have requirements around it while still conforming to schema. |
@tlivings - thank you for clarification and input. If I understand correctly, you're referring to the usage of JSON Schema for the Schema Object and not the specification as a whole. In that case, I mostly agree with you. I don't know if Normally when describing it, I say that the Schema Object uses an extended subset of the JSON Schema, since we do extend it. That's not the wording used in the spec and I may need to change that. As @mohsen1 said though, this is not going to change for 2.0 but it's a good point for the next version of the spec. |
Yeah, as mentioned above, using hyper schema extensions in the spec may be the right path forward in the future. Fully aware than nothing can change this version. Just wanted to raise the issue! Thanks. |
|
@viswguru - I don't really see what this has to do with the issue at hand. Please use the Google group for general support questions. |
@webron: bumping this thread for a little more focus. Still would like to call for any primitive type to be validatable by value alone. |
@tlivings As I understand, the |
A primitive type is a type that can be validated on value alone. For something like file, hyper media extensions can be used. |
Tackling PR: #741 |
PR #878 removed |
Woot! |
Related: #3024 |
Adding the
file
"primitive" is not something that is out-of-the-box validation by any JSON schema validator. It seems like this type is not a primitive, and also requires additional checks forconsumes
.This requires a special edge case just for validating when
type
isfile
. And in fact, it is not validating thetype
, but rather theconsumes
.It seems lie the appropriate path would be to not add to JSON schema spec, since developers implementing tools for swagger would simply perform their own assertions for multipart/form at the framework level.
The text was updated successfully, but these errors were encountered: