devexperts / devexperts/swagger-codegen-ts

JSONSchema case is not supported

Open
#180 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
80
Forks
17
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.