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 readOnly, writeOnly (>= Draft 7) #55
Comments
The specification doesn't seem to get into how these keywords relate to validating data, though I can see how specifying a validation context could be useful. I don't plan on working on this myself, but PRs are always welcome. |
There is an example how one could handle |
If someone is interested in this as well: Actually using the added hooks to hack in |
This adds support for OpenAPI 3.0 documents and schemas. There's no published meta schema or dialect that I could find, so the meta schema refs into the published document schema instead. Everything is based off of draft 4. The keywords additions are `nullable` (implemented in `type`), `readOnly`, and `writeOnly`. There are also a couple new formats (`byte` and `binary`). `readOnly` and `writeOnly` are implemented with a new option called `access_mode` that triggers errors for invalid access, ie a `writeOnly` property is present in "read" access mode. It also removes keys from `required` depending on the specified mode. These features are implemented in draft 2020-12 because they seemed like they might be useful elsewhere and they're off by default. `nullable` just adds "null" to the allowed `type` array. You'd probably get better errors with an actual `Nullable` keyword class, but it didn't seem worth it at this point. Related: - #55
Features: - Draft 2020-12 support - Draft 2019-09 support - Output formats - Annotations - OpenAPI 3.1 schema support - OpenAPI 3.0 schema support - `insert_property_defaults` in conditional subschemas - Error messages - Non-string schema and data keys See individual commits for more details. Closes: - #27 - #44 - #55 - #91 - #94 - #116 - #123
This adds support for OpenAPI 3.0 documents and schemas. There's no published meta schema or dialect that I could find, so the meta schema refs into the published document schema instead. Everything is based off of draft 4. The keywords additions are `nullable` (implemented in `type`), `readOnly`, and `writeOnly`. There are also a couple new formats (`byte` and `binary`). `readOnly` and `writeOnly` are implemented with a new option called `access_mode` that triggers errors for invalid access, ie a `writeOnly` property is present in "read" access mode. It also removes keys from `required` depending on the specified mode. These features are implemented in draft 2020-12 because they seemed like they might be useful elsewhere and they're off by default. `nullable` just adds "null" to the allowed `type` array. You'd probably get better errors with an actual `Nullable` keyword class, but it didn't seem worth it at this point. Related: - #55
Features: - Draft 2020-12 support - Draft 2019-09 support - Output formats - Annotations - OpenAPI 3.1 schema support - OpenAPI 3.0 schema support - `insert_property_defaults` in conditional subschemas - Error messages - Non-string schema and data keys See individual commits for more details. Closes: - #27 - #44 - #55 - #91 - #94 - #116 - #123
This adds support for OpenAPI 3.0 documents and schemas. There's no published meta schema or dialect that I could find, so the meta schema refs into the published document schema instead. Everything is based off of draft 4. The keywords additions are `nullable` (implemented in `type`), `readOnly`, and `writeOnly`. There are also a couple new formats (`byte` and `binary`). `readOnly` and `writeOnly` are implemented with a new option called `access_mode` that triggers errors for invalid access, ie a `writeOnly` property is present in "read" access mode. It also removes keys from `required` depending on the specified mode. These features are implemented in draft 2020-12 because they seemed like they might be useful elsewhere and they're off by default. `nullable` just adds "null" to the allowed `type` array. You'd probably get better errors with an actual `Nullable` keyword class, but it didn't seem worth it at this point. Related: - #55
Features: - Draft 2020-12 support - Draft 2019-09 support - Output formats - Annotations - OpenAPI 3.1 schema support - OpenAPI 3.0 schema support - `insert_property_defaults` in conditional subschemas - Error messages - Non-string schema and data keys - Schema bundling See individual commits for more details. Closes: - #27 - #44 - #55 - #91 - #94 - #116 - #123 - #136
This adds support for OpenAPI 3.0 documents and schemas. There's no published meta schema or dialect that I could find, so the meta schema refs into the published document schema instead. Everything is based off of draft 4. The keywords additions are `nullable` (implemented in `type`), `readOnly`, and `writeOnly`. There are also a couple new formats (`byte` and `binary`). `readOnly` and `writeOnly` are implemented with a new option called `access_mode` that triggers errors for invalid access, ie a `writeOnly` property is present in "read" access mode. It also removes keys from `required` depending on the specified mode. These features are implemented in draft 2020-12 because they seemed like they might be useful elsewhere and they're off by default. `nullable` just adds "null" to the allowed `type` array. You'd probably get better errors with an actual `Nullable` keyword class, but it didn't seem worth it at this point. Related: - #55
Features: - Draft 2020-12 support - Draft 2019-09 support - Output formats - Annotations - OpenAPI 3.1 schema support - OpenAPI 3.0 schema support - `insert_property_defaults` in conditional subschemas - Error messages - Non-string schema and data keys - Schema bundling See individual commits for more details. Closes: - #27 - #44 - #55 - #91 - #94 - #116 - #123 - #136
Released in 2.0.0. Use JSONSchemer.schema(schema).validate(data, :access_mode => 'read') |
The
readOnly
andwriteOnly
keywords (see specification (Draft 7)) make validation behave differently in the context of a write or read operation.Unfortunately this does not seem to be covered by JSON-Schema-Test-Suite.
I found one (Java) library that supports this.
The text was updated successfully, but these errors were encountered: