-
Notifications
You must be signed in to change notification settings - Fork 7
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
Optional and Object for InterTypes #96
Conversation
8587248
to
73a25e5
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #96 +/- ##
==========================================
+ Coverage 90.64% 90.75% +0.11%
==========================================
Files 22 22
Lines 2074 2110 +36
==========================================
+ Hits 1880 1915 +35
- Misses 194 195 +1 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@olynch I'm still double checking a few things but I was wondering if you've noticed the JSON Schema validating on any JSON object. Would it break InterTypes to have the user specify which types get definitions? I think that might help a bit as to not stuff a bunch of definitions at the top level
) | ||
OptionalType(elemtype) => begin | ||
schema = tojsonschema(elemtype) | ||
schema[:type] = [schema[:type], "null"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The schema of a type can be a list including the string null? Is this a JSONSchema idiom?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so? This is what showed up on the jsonschema website when I poked around for it, but I'm no jsonschema expert.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fivegrant can probably confirm that it is what he would expect for a nullable field.
I'm not really sure what you mean by this with regard to "which types get definitions"? |
@olynch If you look at the Petrinet Schema, you'll notice it only validates on object. InterTypes, however, produces a bunch of "$defs": {
"Parameter": {
"type": "object",
"properties": {
"type": {
"type": "string",
"$comment": "Str"
},
"value": {
"type": "number",
"$comment": "F64"
}
},
"required": [
"type",
"value"
]
},
"Condition": {
"type": "object",
"properties": {
"type": {
"type": "string",
"$comment": "Str"
},
"value": {
"type": "number",
"$comment": "F64"
},
"domain_mesh": {
"type": "string",
....
"Thing": {
"type": "object",
"properties": {
"a": {"type": "Condition"}, "b":{"type":"Parameter"}}
}
} When validating against this schema with a bunch of |
This is a valid point, but not really relevant to this PR. Can you open an issue for it? But also, I would argue that this is a better way of doing it, because it maps closer to how one declares types in the programming languages that use intertypes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@olynch I brought the $defs
issue because I think adding objects made the JSON Schema noticeably more permissive but it's been a minute since I've validated previously
Anyway, I waited to review this PR until I made sure everything worked in the MR one and it does so LGTM!
|
No description provided.