Skip to content
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

Support validation of model objects via JSON Schema #26

Open
ColinEberhardt opened this issue Jul 1, 2022 · 3 comments
Open

Support validation of model objects via JSON Schema #26

ColinEberhardt opened this issue Jul 1, 2022 · 3 comments
Labels

Comments

@ColinEberhardt
Copy link
Collaborator

As per https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.0.md#properties

OpenAPI supports a subset of JSON Schema rules for validating values.

@jhowlett-scottlogic
Copy link
Contributor

jhowlett-scottlogic commented Oct 25, 2022

If im not mistaken generate.js:49 await SwaggerParser.validate(cloneSchema(schema)); does this.

I tested by changing the Pet model in the petstore.json swagger schema.
object -> objct and it failed to validate schema.
I did the same with the type -> tyrpe and it failed to validate

I also tested the petsotre.json schema that i converted into yml and it also gave validation errors.

the petstore.json is OpenAPI v3.0.2

@ColinEberhardt
Copy link
Collaborator Author

What I'm considering with this issue is that when an object has constraints associated with it, we generate a model object that enforces those constraints. Does that make sense?

@jhowlett-scottlogic
Copy link
Contributor

Ok, yes that makes sense. @osouthwell-scottlogic had a little exploration into this and found that for CSharp it will be simple as you can add validation to model objects but TypeScript will be a little more time consuming as all supported validators will need to be written by hand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants