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

Request of the const field support #229

Closed
belgraviton opened this issue May 27, 2022 · 0 comments · Fixed by #283
Closed

Request of the const field support #229

belgraviton opened this issue May 27, 2022 · 0 comments · Fixed by #283

Comments

@belgraviton
Copy link

What are you trying to do?
We use this library to automatically generate classes to validate our data format.

Example Schema and code

import python_jsonschema_objects as pjs
exclass = {
    "type": "object",
    "properties": {
        "region_type": {  "const": "RECTANGLE"  }
    },
    "title": "Example"
}
builder = pjs.ObjectBuilder(exclass)
available_classes = builder.build_classes()

Error: "NotImplementedError: Unable to parse schema object '{'const': 'RECTANGLE', 'raw_name': 'region_type'}' with no type and no reference"

Is this a currently unsupported jsonschema directive? If so, please link to the documentation

I'd like to be able to use the format validator from v7, as described here: https://json-schema.org/understanding-json-schema/reference/generic.html#constant-values

Do you have an idea about how this should work?

Support of "const" field in schema could be realized in a way similar to "enum".

"region_type": { "enum": [ "RECTANGLE" ] }

Last format in my json schema works.

cwacek added a commit that referenced this issue Mar 5, 2024
cwacek added a commit that referenced this issue Mar 5, 2024
This issue occurred because allOf was set but the matching set of schemas were
null, so the union operation failed. This just handles that specific case.

The test is still failing because this schema appears to also use the `const`
keyword which isn't supported per #229
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant