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

Fails with type unions #39

Open
Rolandisimo opened this issue Sep 21, 2020 · 3 comments
Open

Fails with type unions #39

Rolandisimo opened this issue Sep 21, 2020 · 3 comments

Comments

@Rolandisimo
Copy link

Rolandisimo commented Sep 21, 2020

Interface

interface Foo {
    id: number | null;
}

fails the validation by saying Error: Foo.id should be number

Validator file

...
properties: {
    id: {
        type: 'number',
    },
}
...
@samywang92
Copy link

I am also having the same issue.

Additionally, if I use annotations to assign the type the Validator file out puts an extra set of quotes outside the brackets.

export interface Foo {
  /** 
   * @TJS-type ['array', 'null']
   */
  foo?: Array<string> | null
}

Validation output:

  foo: {
     type: "['array', 'null']"
  },

@jacobcoro
Copy link

jacobcoro commented Jan 29, 2021

This seems like a dealbreaker...
So did you guys decide to continue to use this? If you don't have too many unions, I guess it isn't a big deal, this lib will still probably save a lot of time.
So if you have unions, just manually go in and edit the produced JSONSchema? Add oneOf: { union1, union2 }

@Rolandisimo
Copy link
Author

@Jewcub I guess you can do that. I decided not to use this tool because of the basic functionality it offers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants