Azure / Azure/azure-functions-openapi-extension
Enums values are modified inconsistently, when enum is used as a type constraint for a parameter in path
- Dominant language
- C#
- Stars
- 388
- Forks
- 202
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the issue**
Enums values are modified inconsistently, when enum is used as a type constraint for a parameter in path.
**To Reproduce**
Steps to reproduce the behavior:
1. Set up an enum with JsonConverterAttribute and decorate members with EnumMemberAttribute as shown in the screen shot 1.
2. Set up an endpoint, where the enum we set up before is used as OpenApiParameter in ParameterLocation.Path. See screen shot 2.
3. Generate the openapi document. The tooling as attempted and failed to convert the enum values to camelCase.
**Expected behavior**
Enum shows up in the document as defined in code. The tooling does not enforce the produces document to be valid in other places either (for example, you can have Required = false for ParameterLocation.Path and invalid document is generated),
**Screenshots**
1: Setting the troublesome enum up for testing:

2: Setting up the endpoint:

3: The casing of enum values are altered in an arbitrary manner:

**Environment (please complete the following information, if applicable):**
- Openapi verison 3.0.1
- Microsoft.Azure.WebJobs.Extensions.OpenApi.Core 1.3.0
- Microsoft.Azure.WebJobs.Extensions.OpenApi 1.3.0
- Microsoft.OpenApi 1.3.1
- Local windows 11 dev environment, func --version: 4.0.4544
**Additional context**
When the troublesome enum is used as a property in a request body, the enum values are displayed on the document as expected:

Contributor guide
Research direction
Reproduce the issue with an enum using JsonConverterAttribute and EnumMemberAttribute as an OpenApiParameter at ParameterLocation.Path, then generate the OpenAPI document. Compare the path-parameter enum values with the same enum used in a request-body property; done means the path values remain exactly as defined in code.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, csharp, openapi
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100