Skip to content

Commit 5d62964

Browse files
committed
docs(api-sdk): enums specific properties use-case
1 parent 95345f2 commit 5d62964

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

.github/ISSUE_TEMPLATE/2-AMA-SDK-ISSUE-FORM.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ body:
1717
core,
1818
create,
1919
schematics,
20-
showcase-sdk
20+
showcase-sdk,
2121
swagger-builder
2222
]
2323
validations:

docs/api-sdk/COMPOSITION_INHERITANCE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export interface ExtendedErrorModel {
6262

6363
The addition of a discriminator allows a hierarchy between the models and the possibility to identify which child class
6464
a model can be casted into.
65-
For example, let's consider a Pet object and its two class child Cat and Dog:
65+
For example, let's consider a Pet object and its two child classes Cat and Dog:
6666

6767
```yaml
6868
components:
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Issues and workarounds
2+
3+
## `properties` for `allOf` instruction
4+
5+
Currently, using `properties` for the `allOf` instruction is not supported by the SDK generator. For instance, it can incorrectly handle `enum` generation.
6+
7+
```yaml
8+
Dog:
9+
allOf:
10+
- $ref: '#/components/schemas/Pet'
11+
properties:
12+
bark:
13+
type: boolean
14+
breed:
15+
type: string
16+
enum: [Dingo, Husky, Retriever, Shepherd]
17+
```
18+
19+
It will not generate the `breed` enum.
20+
21+
As a workaround, you can pass the properties as an object to the `allOf` array as follows:
22+
23+
```yaml
24+
Dog:
25+
allOf:
26+
- $ref: '#/components/schemas/Pet'
27+
- type: object
28+
properties:
29+
bark:
30+
type: boolean
31+
breed:
32+
type: string
33+
enum: [Dingo, Husky, Retriever, Shepherd]
34+
```
35+
36+
This will generate:
37+
```typescript
38+
export type BreedEnum = 'Dingo' | 'Husky' | 'Retriever' | 'Sheperd';
39+
```
40+
41+
The issue is tracked via https://github.com/AmadeusITGroup/otter/issues/2832.

0 commit comments

Comments
 (0)