-
Notifications
You must be signed in to change notification settings - Fork 8
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
Missing "type" declarations #5
Comments
|
Thank you, Im unfamiliar with JSONSchema so I'm not sure what the rules are. I was looking at the possibility of on the fly transforming your schema validations into a validation layer to get some of the business rules represented therein for free. I was hoping for a shortcut by inheriting your business rules, but I think I'm going to have to consider some other options. Thanks again for this repo, its a huge help. |
@i8beef depending on the language you're using there might be validation options already available: https://json-schema.org/implementations.html#validators |
Im not validating Google Home messages, I'm validating app config structures that are needed for my bridging app. I tried to keep said config as close to the object structures you use, where each device has attributes, commands and states. The attributes are 1:1 so I load your schema into a validator directly and it works great. I was hoping to do the same for commands and states by transforming your schema into one that would validate my config structures, but I've found that doesn't work that great. oneOf, anyOf, enums, "missing" type declarations (that I can take from other places if I do this differently) kind of shot that in the foot. Not your issue, I was just looking for a short cut. It'll be better if I parse your schema, and then recursively loop through it to generate a new JSON file, and parse THAT instead for my validations, where I can take an additive approach instead of a subtractive one. Thanks again! |
@i8beef for applying transformation on JSON schemas you might want to take a look at https://cuelang.org as it provides a nice declarative way to work with schema and data. I'd be happy to add missing "type" declaration for enum (2) if it makes things easier to consume by downstream tool, I'm just not sure if it wouldn't make things more confusing for top-level anyOf/oneOf (1). |
Honestly I'd prefer you just follow whatever the JSONSchema best practices are here. My questions were more just about triggering a review of these if there was something missed, or if it was intentional. What I was trying to do was questionable, and its not surprising I hit issues. You shouldn't pollute your schemas for me here unless there's a legitimate deviation from what the JSON Schema specs say you should do. Edit: https://json-schema.org/understanding-json-schema/reference/combining.html They seem to point to your enum usage being valid "factoring out" of common elements (type), so I don't see a big reason to modify. |
We currently only enforce that all sub-schemas with |
Something I noticed in a few places, and I'm not sure if this is valid JsonSchema or not...
The text was updated successfully, but these errors were encountered: