fix: emit required array for non-nullable action parameters in requestBody#355
Open
axherrm wants to merge 5 commits into
Open
fix: emit required array for non-nullable action parameters in requestBody#355axherrm wants to merge 5 commits into
axherrm wants to merge 5 commits into
Conversation
Comment on lines
+1637
to
+1638
| if (!p.$Nullable && !p[voc.Core.OptionalParameter]) | ||
| requiredParameters.push(p.$Name); |
Contributor
There was a problem hiding this comment.
This makes collection-valued parameters required, although OData-Protocol, section 11.5.6.1 allows their omission.
The interpretation of an omitted non-binding collection-valued parameter is up to the service regardless of its nullability or optionality.
Note also the failed test.
Author
There was a problem hiding this comment.
thank you for the comment - does the fix I added resolve the issue?
Also, I commited the openapi artifacts after test run so that they should have no diff in CI/CD (diff was the required array which is new and needs to be added to the artifacts to my understanding). Can you permit a new CI/CD run
HeikoTheissen
approved these changes
Jul 3, 2026
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.
Fixes #354
Problem
pathItemActionbuilt therequestBodyschema with apropertiesobjectfor every non-binding parameter but never emitted a
requiredarray.As a result, downstream OpenAPI consumers (validators, code generators,
LLM-based agents) treated all action parameters as optional, even when
Nullable="false"was set — causing the service to return400 Bad Requestwhen those parameters were omitted.
OData 4.01 Protocol §11.5.5.1 states that non-binding parameters that are
neither nullable nor annotated with
Core.OptionalParametermust besupplied in the request body. The generated OpenAPI document should reflect
this constraint.
Fix
In
pathItemAction, collect the names of parameters where$Nullableisnot
trueand@Core.OptionalParameteris not set, then emit them asrequiredon the requestBody schema object. This mirrors the logic alreadypresent in
pathItemFunctionfor URL parameters (line 1720).Changes
lib/csdl2openapi.js—pathItemAction: compute and conditionallyemit
requiredarray on the requestBody schema.test/csdl2openapi.test.js— new test case"action with nullable and not nullable parameters"covering all fourcombinations: non-nullable (required), typed non-nullable (required),
$Nullable: true(not required), and@Core.OptionalParameter(notrequired).
test/annotations.test.js— updated "Default Namespace" snapshot toinclude the now-emitted
requiredarray.examples/TripPin.openapi3.json— updatedShareTripactionrequestBody (
userName,tripIdare bothNullable="false").examples/odata-rw-v3.openapi3.json— updatedDiscountandIncreaseSalariesaction requestBodies (single non-nullable parametereach).