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

docs(api-sdk): enums specific properties use-case #3013

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/2-AMA-SDK-ISSUE-FORM.yaml
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ body:
core,
create,
schematics,
showcase-sdk
showcase-sdk,
swagger-builder
]
validations:
2 changes: 1 addition & 1 deletion docs/api-sdk/COMPOSITION_INHERITANCE.md
Original file line number Diff line number Diff line change
@@ -62,7 +62,7 @@ export interface ExtendedErrorModel {

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

```yaml
components:
41 changes: 41 additions & 0 deletions docs/api-sdk/ISSUES_AND_WORKAROUNDS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Issues and workarounds

## `properties` for `allOf` instruction

Currently, using `properties` along with the `allOf` instruction is not supported by the SDK generator. For instance, it can incorrectly handle `enum` generation.

```yaml
Dog:
allOf:
- $ref: '#/components/schemas/Pet'
properties:
bark:
type: boolean
breed:
type: string
enum: [Dingo, Husky, Retriever, Shepherd]
```
It will not generate the `breed` enum.

As a workaround, you can pass the properties as an object to the `allOf` array as follows:

```yaml
Dog:
allOf:
- $ref: '#/components/schemas/Pet'
- type: object
properties:
bark:
type: boolean
breed:
type: string
enum: [Dingo, Husky, Retriever, Shepherd]
```

This will generate:
```typescript
export type BreedEnum = 'Dingo' | 'Husky' | 'Retriever' | 'Shepherd';
```

The issue is tracked via https://github.com/AmadeusITGroup/otter/issues/3017.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The issue is tracked via https://github.com/AmadeusITGroup/otter/issues/3017.
> [!INFO]
> The issue is tracked via https://github.com/AmadeusITGroup/otter/issues/3017.