Skip to content

fix(generator): wrap enum operation responses in value property - #931

Open
Hardik K (hardikkaurani) wants to merge 2 commits into
microsoft:mainfrom
hardikkaurani:fix/wrap-enum-operation-response
Open

Hardik K (hardikkaurani) wants to merge 2 commits into
microsoft:mainfrom
hardikkaurani:fix/wrap-enum-operation-response

Conversation

@hardikkaurani

Copy link
Copy Markdown

Summary

Resolves #674. When an OData operation (function or action) returns an Enum type, the OData specification (OData to OpenAPI Mapping §4.3 and OData JSON Format §9) requires individual primitive or enum operation responses to be formatted as an object with a single value property containing the primitive/enum value ({"value": ...}).

Previously, OpenApiResponseGenerator.CreateOperationResponse only checked returnType.IsPrimitive(), causing enum return types to fall into the default else branch which generated the enum schema directly without the required value object wrapper.

Changes

  • Updated OpenApiResponseGenerator.cs to check else if (returnType.IsPrimitive() || returnType.IsEnum()) so enum operation responses are wrapped in an object with property value.
  • Added unit test CreateResponseForEdmFunctionReturningEnumWrapsInValueProperty in OpenApiResponseGeneratorTests.cs verifying the response schema contains an object with property value.

@hardikkaurani
Hardik K (hardikkaurani) requested a review from a team as a code owner October 21, 2026 06:00
Copilot AI balanced review requested due to automatic review settings October 21, 2026 06:00
@hardikkaurani

Copy link
Copy Markdown
Author

Hi Vincent Biret (@baywet)! This PR fixes #674 by ensuring that operation responses returning Enum types are wrapped in an object with a �alue property according to the OData JSON specification (§9) and OData-to-OpenAPI mapping rules (§4.3), aligning enum return types with primitive return types. Unit test included. Whenever you have time, please take a look. Thank you!

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enum return value schema is wrong

2 participants