-
Notifications
You must be signed in to change notification settings - Fork 11
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
Unable to use readOnly and writeOnly for a property and have it validated #114
Comments
What this library does is, it extracts the examples out of the OpenAPI-description, creates a map between the examples and the corresponding schema and then validates the examples against the schema, via JSON-schema-validator. Its context (request, response) are not taken into consideration, at the moment and it also could not be validated with the JSON-schema-validator but would have to be checked additionally. This is a not so trivial change. I'll add it on the todo-list, but it may take a while to implement this. |
I will add a reference to the OAS 3.0 expected behavior.
https://spec.openapis.org/oas/v3.0.0#fixed-fields-19 ajv seems not to support |
I did some digging and it seems support for read/write only might be relatively easy. At least for examples in paths.
For composed models, it is a bit more tricky. Searching for 'required must consider |
As you wrote in #114 (comment),
The specs to the to-validate examples are determined after the examples have been collected. At this point it is not known (yet) whether it is a request- or response-spec, also at this point modifying the spec (removing / adding / setting properties) is not intended and would require not-so-trivial changes in the core and extensive testing to ensure that everything else still works as before. |
https://swagger.io/docs/specification/data-models/data-types/#readonly-writeonly
Depending on where the property is defined (request vs. response) I would expect the validator to account for readOnly and writeOnly fields. I would also expect that if a property is marked as "required", that property would not be validated for being required if either it showed up in the response as writeOnly or in the request as readOnly.
The text was updated successfully, but these errors were encountered: