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

Some JSON schemas cannot be expressed using Wing's json structs #2023

Open
eladb opened this issue Apr 10, 2023 · 3 comments
Open

Some JSON schemas cannot be expressed using Wing's json structs #2023

eladb opened this issue Apr 10, 2023 · 3 comments
Labels
🐛 bug Something isn't working 🛠️ compiler Compiler

Comments

@eladb
Copy link
Contributor

eladb commented Apr 10, 2023

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.

@eladb eladb added the 🐛 bug Something isn't working label Apr 10, 2023
@github-actions
Copy link

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!

@github-actions
Copy link

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!

Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working 🛠️ compiler Compiler
Projects
Status: 🤝 Backlog - handoff to owners
Development

No branches or pull requests

2 participants