Azure / Azure/azure-functions-openapi-extension

How to display Enum values in generated OpenAPI Document as 'string' instead of 'numbers'?

Open
#555 5 comments 7 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
388
Forks
202
PR merge metrics
No merged PRs in 30d

Description

I have defined a Transport enum as below, i want the Open API Specification to show the enum values as string instead of numeric.

```
[JsonConverter(typeof(JsonStringEnumConverter))]
public enum BusinessFunction
{
[EnumMember(Value = "Liner")]
Liner = 100000000,
[EnumMember(Value = "Trucking")]
Trucking = 100000001
}
```
**Current behaviour**
![image](https://user-images.githubusercontent.com/7764072/218457996-2c293c3e-fb02-4ee9-9b2f-f587a11b54da.png)

**Environment
- Azure Function Isolated
- .Net 7.0, C#
- Azure Function Host 4.0
- Microsoft.Azure.Functions.Worker.Extensions.OpenApi (1.5.1)

Contributor guide

Open the contributing guide

Research direction

Reproduce the generated document in an Azure Functions isolated app using .NET 7, Azure Functions Host 4.0, and Microsoft.Azure.Functions.Worker.Extensions.OpenApi 1.5.1 with the shown enum. Inspect the generated schema and determine whether the enum is represented as string values rather than numeric values; done when the OpenAPI document reflects the requested representation.

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
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.