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

Exception when additionalProperties is a boolean. #69

Open
LorrinWWW opened this issue Feb 6, 2024 · 4 comments
Open

Exception when additionalProperties is a boolean. #69

LorrinWWW opened this issue Feb 6, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@LorrinWWW
Copy link

Boolean value will raise exception:'int' object has no attribute 'get'
Expected behaviours: https://json-schema.org/understanding-json-schema/reference/object#additional-properties

@noamgat noamgat added the bug Something isn't working label Feb 10, 2024
@noamgat
Copy link
Owner

noamgat commented Feb 10, 2024

Thanks for the report!
Can you please provide a reproducing example so I can fix it?

@LorrinWWW
Copy link
Author

When additionalProperties is False, it should be the same to without this field.
For example, given schema:

{
 "type": "object",
 "properties": {
   "number": { "type": "number" },
   "street_name": { "type": "string" },
   "street_type": { "enum": ["Street", "Avenue", "Boulevard"] }
 },
 "additionalProperties": false
}

This should be a valid output:

{ "number": 1600, "street_name": "Pennsylvania", "street_type": "Avenue" }

When additionalProperties is True, it allows additional entries with any data types.
if additionalProperties is { "type": <<data_type>> }, it allows additional entries with <<data_type>> data type.
For example, given schema:

{
 "type": "object",
 "properties": {
   "number": { "type": "number" },
   "street_name": { "type": "string" },
   "street_type": { "enum": ["Street", "Avenue", "Boulevard"] }
 },
 "additionalProperties": { "type": "string" } 
}

This should be a valid output:

{ "number": 1600, "street_name": "Pennsylvania", "street_type": "Avenue", "description": "NW"}

where "description" is an additional entry where its corresponding data type could only be "string".

@noamgat Thank you!

@jamestwhedbee
Copy link

@noamgat I am running into this too, I'd really like to be able to pass / enforce "additionalProperties": false

@gcalmettes
Copy link
Contributor

Should be fixed in Master.

see #129 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants