danielgtaylor / danielgtaylor/huma
Support Enum as Separate Type in OpenAPI Spec for Client Generators
- Dominant language
- Go
- Stars
- 4.4k
- Forks
- 285
- Avg merge
- 40m
- Merged PRs (30d)
- 1
Description
Is there a way to add enums as separate types in the OpenAPI specification file, rather than using inline enum definitions. This will allow client generators (e.g., TypeScript/JavaScript) to create reusable enum types that can be used by applications like Angular, React, etc.
how "enums" are generated right now:
```
"ObjectFoo": {
"properties": {
"fooType": {
"enum": [
"ENUM_Value_ONE",
"ENUM_Value_TWO",
"ENUM_Value_THREE"
],
"example": "ENUM_Value_ONE",
"type": "string"
}
}
}
```
how "enums" could be generated as extra types:
```
components:
schemas:
FooTypeEnum:
type: string
enum:
- ENUM_Value_ONE
- ENUM_Value_TWO
- ENUM_Value_THREE
"ObjectFoo": {
"properties": {
"fooType": {
"$ref": "#/components/schemas/FooTypeEnum"
}
}
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.