Azure / Azure/azure-functions-openapi-extension
Question - Should enums really generate with a default?
- Dominant language
- C#
- Stars
- 388
- Forks
- 202
- PR merge metrics
- No merged PRs in 30d
Description
Why does an enum property get a default but other non-nullable types do not?
```
public Country? Country { get; set; }
public int Version { get; set; }
```
Will generate as
```
"country": {
"format": "int32",
"default": 1,
"enum": [
1,
2
],
"type": "integer"
},
"version": {
"format": "int32",
"type": "integer"
},
```
This resulted in a hard to detect issue once we generated an API client based on the swagger file since the client's model generated with the default specified so even if the API returned a null value the model would still have a value.
Contributor guide
Research direction
No file, test, or entry point is named. Start by locating the OpenAPI schema generation path for enum properties, then compare the generated schemas for the nullable Country enum and non-nullable Version property; done means determining whether the enum default is intentional and, if not, confirming it is absent from the schema.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, csharp, openapi
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100