Repository navigation
fix(generator): wrap enum operation responses in value property - #931
Open
Hardik K (hardikkaurani) wants to merge 2 commits into
Open
Hardik K (hardikkaurani) wants to merge 2 commits into
Hardik K (hardikkaurani) wants to merge 2 commits into
Conversation
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! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
valueproperty containing the primitive/enum value ({"value": ...}).Previously,
OpenApiResponseGenerator.CreateOperationResponseonly checkedreturnType.IsPrimitive(), causing enum return types to fall into the defaultelsebranch which generated the enum schema directly without the requiredvalueobject wrapper.Changes
OpenApiResponseGenerator.csto checkelse if (returnType.IsPrimitive() || returnType.IsEnum())so enum operation responses are wrapped in an object with propertyvalue.CreateResponseForEdmFunctionReturningEnumWrapsInValuePropertyinOpenApiResponseGeneratorTests.csverifying the response schema contains an object with propertyvalue.