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

JSONSchema case is not supported #180

Open
Geksanit opened this issue Dec 28, 2023 · 0 comments
Open

JSONSchema case is not supported #180

Geksanit opened this issue Dec 28, 2023 · 0 comments

Comments

@Geksanit
Copy link
Contributor

schema.yaml

...
components:
  schemas:
    BaseSchema:
      type: object
      properties:
        type:
          type: string
          enum: 
          - FOO
          - BAR
          - BAZ
      required:
      - type

    FooSchema:
      allOf:
      - $ref: '#/components/schemas/BaseSchema'
      - type: object
        properties:
          type:
            type: string
            enum:
            - FOO

It is correct JSONSchema
FooSchema equal type:
type FooSchema = { type: 'FOO' | 'BAR' | 'BAZ' } & { type: 'FOO' | undefined} -> { type: 'FOO' }
generated code:

export type BaseSchema = { type: 'FOO' | 'BAR' | 'BAZ' };
export type FooSchema = BaseSchema & { type: Option<'FOO'> };

Nothing can match type FooSchema. I understand that this is the result of a combination of optionFromNullable and intersection. It turns out that we do not fully support the JSONSchema. We could throw away the mistake of not supporting this case.
Let's discuss this and think about a solution.

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

1 participant