acacode / acacode/swagger-typescript-api
`XxMapping` for `discriminator` doesn’t account for `generateUnionEnums`
- Ngôn ngữ chính
- TypeScript
- Star
- 4.1k
- Fork
- 436
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
## Issue
When setting `generateUnionEnums` to true, the mapping `Key` generics should be set explicitly as strings rather than using the enum mapping.
Found on version `13.0.3`
### Setup
That is, in the following situation:
```yaml
BranchName:
type: string
enum:
- one
- two
Root:
type: object
discriminator:
propertyName: branch
mapping:
one: '#/components/schemas/BranchA'
two: '#/components/schemas/BranchB'
properties:
branch:
$ref: '#/components/schemas/BranchName'
```
### Expected output
```ts
export type BranchName = 'one' | 'two';
export type Root = BaseRoot &
(
| BaseRootBranchMapping<'one', BranchA>
| BaseRootBranchMapping<'two', BranchB>
);
```
### Current output
```ts
export type BranchName = 'one' | 'two';
export type Root = BaseRoot &
(
| BaseRootBranchMapping
| BaseRootBranchMapping
);
```
Minimal full yaml to reproduce
```yaml
openapi: 3.0.0
info:
title: Broken branches
version: 0.0.0
paths: {}
components:
schemas:
BranchName:
type: string
enum:
- one
- two
Root:
type: object
discriminator:
propertyName: branch
mapping:
one: '#/components/schemas/BranchA'
two: '#/components/schemas/BranchB'
properties:
branch:
$ref: '#/components/schemas/BranchName'
BranchA:
type: object
BranchB:
type: object
```
Expected output:
```ts
export type BranchName = 'one' | 'two';
export type Root = BaseRoot & (BaseRootBranchMapping<'one', BranchA> | BaseRootBranchMapping<'two', BranchB>);
export type BranchA = object;
export type BranchB = object;
interface BaseRoot {
branch?: BranchName;
}
type BaseRootBranchMapping = {
branch: Key;
} & Type;
```
Current output:
```ts
export type BranchName = 'one' | 'two';
export type Root = BaseRoot &
(BaseRootBranchMapping | BaseRootBranchMapping);
export type BranchA = object;
export type BranchB = object;
interface BaseRoot {
branch?: BranchName;
}
type BaseRootBranchMapping = {
branch: Key;
} & Type;
```
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Đánh giá
Issue này chưa được đánh giá.