Some JSON schemas cannot be expressed using Wing's json structs
Opened this issue · 5 comments
I tried this:
Wing's json structs (structs that can be serialized into JSON) are designed to be able to express cloud data shapes. As such, they are closely related to JSON Schemas.
Currently, Wing's type system doesn't have the ability to express everything that JSON schemas can express.
For example, the oneOf
and anyOf
annotations can be used in JSON schemas to denote a union of possible types for a field, and this is currently not supported by the Wing type-system.
Consider the following JSON schema:
{
"oneOf": [
{
"type": "string",
"maxLength": 10
},
{
"type": "integer",
"minimum": 0
}
]
}
I expected this:
I expect to be able to model this in Winglang somehow.
Instead, this happened:
I don't have a way to model this.
Is there a workaround?
We can start by using Json
to model these schemas without strong typing.
If that's suitable for my use case, I could just choose the first schema from the anyOf
or oneOf
arrays and use that, but this doesn't really address the underlying issue.
Component:
Language Design
Wing Version:
No response
Node.js Version:
No response
Platform(s):
No response
Anything else?
No response
Community Note
Please vote by adding a 👍 reaction to the issue to help us prioritize.
If you are interested to work on this issue, please leave a comment.
Hi,
This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days.
Feel free to re-open this issue when there's an update or relevant information to be added.
Thanks!
Hi,
This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days.
Feel free to re-open this issue when there's an update or relevant information to be added.
Thanks!
Hi,
This issue hasn't seen activity in 90 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days.
Feel free to re-open this issue when there's an update or relevant information to be added.
Thanks!
Hi,
This issue hasn't seen activity in 90 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days.
Feel free to re-open this issue when there's an update or relevant information to be added.
Thanks!