-
-
Notifications
You must be signed in to change notification settings - Fork 893
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
[RFC] Json Schema Validations #2131
Comments
I'd be willing to put in the effort coding wise, but not sure if this idea would even be worth adding/maintaining for you guys? |
For the record I'm, 👍 for this! |
Implementation wise, what do you think about caching the normalized swagger documentation? We could keep cached instances for v2 and v3? I'm thinking we create an interface for accessing the normalized docs
where type is and then a caching decorator implementation of that, and another that generates the Documentation object and normalizes it accordingly. We could then use that normalized data to grab the definition per entity and run the json schema validator on it. We might even want to add a ChainValidator so we can always enforce json schema, and optionally run SF validations on top of it. |
hmm, one thing to mention that the normal API Platform validations occur on kernel.view which is after the deserialization step. Part of me wonders if the json schema validations should run on the raw JSON data BEFORE deserialization. This could (possibly) mess up the various deserialization formats API Platform supports. It's almost as if, we should decode the value, then run JSON schema validation, then deserialize into the DTO or Entity object accordingly. |
I do validate the need. |
@ragboyjr Are you making progress on this subject, because it's very interesting? |
@fherbin I haven't made much progress on it, I think I hit that road block mentioned on Dec 22, didn't receive any feedback and moved on. |
See also #3828. For the documentation cache I'd suggest using a file that you previously dump as it should be sufficient. Note that on the master branch the OpenApi code has been improved (use the OpenApiFactory). |
Any updates? |
What would you think about allowing JSON Schema Validations for API Resources that we could then expose inside of the generated OpenAPI documentation file?
Most of the basic symfony validations like Assert\Blank, Assert\Length etc are values that could be defined via the json schema vocabulary and a library like https://github.com/justinrainbow/json-schema would be able to parse and validate those definitions.
I don't think this would obviate the need for symfony validations because you might still want to use a custom validation rule or maybe check the db for uniqueness, but a lot of the simple stuff could easily be written as json schema validations.
The text was updated successfully, but these errors were encountered: