-
Notifications
You must be signed in to change notification settings - Fork 5
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 string and null as schema representation #30
Conversation
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.
Generally looks good, thanks, please also add schema as suggested so I can review fully.
}; | ||
|
||
for (final MapEntry(:key, :value) in allDefinitions.entries) { | ||
if (value.oneOf.isNotEmpty) { |
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 just merged another PR tweaking generation for oneOf
, because the schema was not correct, please rebase; sorry about that. It moves the oneOf
in the schema into a property called value
, since that's what we write on the wire.
voidType; | ||
} | ||
|
||
extension type StaticType.fromJson(Map<String, Object?> node) { |
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.
It would be useful to see schema change + code change + generator together, but I don't see the schema change--could you add it please?
There isn't any other test coverage for the generator besides what is in the schema, so it probably makes sense to add something to the schema even if it's just showing the new functionality. In that case please note in the description that the type is currently just there to show the union functionality :)
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 didn't mean to commit the type changes in this PR, but I've added a few types with their schema definitions to test the generator.
844f185
to
44026b6
Compare
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.
Looks good, thanks!
Please fix lint violation
|
In addition to
"type": "object"
, it looks like the schema generator partially supports using"type": "string"
for definitions. Those definitions are broken in unions though, as the generator for unions expects all definitions to be JSON.This PR fixes that, and also adds support for
"type": "null"
definitions. Those are useful as part of unions if we only care about the element type. To model Dart's type hierarchy for instance, we may have anunion StaticType = InterfaceType {...} | NullableType { StaticType inner } | ... | DynamicType
. There is nothing interesting aboutDynamicType
apart from knowing that we're dealing withdynamic
, sonull
makes sense as the underlying JSON representation here.