Mark stored procedure parameters without defaults as required in OpenAPI#3687
Mark stored procedure parameters without defaults as required in OpenAPI#3687souvikghosh04 with Copilot wants to merge 7 commits into
Conversation
|
@copilot please add tests from to support the changes |
Added tests in
Each entity uses a distinct stored procedure so per-entity config metadata doesn't cross-contaminate (entities sharing a source share the same parameter definition). Verified all rows pass with the fix and fail when it's reverted, against a local SQL Server. (79f... latest commit) |
There was a problem hiding this comment.
Pull request overview
Updates OpenAPI generation for stored procedure entities so request schema components correctly flag parameters as required when no config default is available (while still honoring explicit required: false overrides), and extends integration coverage to validate the resulting required set.
Changes:
- Update stored procedure request schema generation to treat parameters as required when
Required == trueor whenRequiredis unset and no config default exists. - Extend OpenAPI integration tests to validate the schema component’s
requiredparameters for stored procedure request bodies across default/override scenarios.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Core/Services/OpenAPI/OpenApiDocumentor.cs | Adjusts stored procedure request schema generation to populate schema.Required based on config-required or absence of config default. |
| src/Service.Tests/OpenApiDocumentor/StoredProcedureGeneration.cs | Adds stored procedure entities and assertions to validate required parameters in the generated OpenAPI schema component. |
RubenCerna2079
left a comment
There was a problem hiding this comment.
LGTM! Approving assuming comments from myself and copilot are resolved.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: RubenCerna2079 <32799214+RubenCerna2079@users.noreply.github.com>
|
/azp run |
|
Azure Pipelines successfully started running 6 pipeline(s). |
Why make this change?
requiredarray on the{entity}_sp_requestschema, so parameters that must be supplied (e.g.firstName,lastName) were not flagged as required.What is this change?
CreateSpRequestComponentSchema(OpenApiDocumentor.cs): a parameter is now marked required when it is explicitly flagged in config or has no default value. Previously only an explicit configrequired: truepopulated the array, which is almost never set, so the array was always empty.IsRequestBodyRequiredlogic (!HasConfigDefault), keeping body-level and property-level required semantics consistent. An explicit configrequired: falseis still honored.How was this tested?
Extended
StoredProcedureGeneration.ValidateRequestBodyContentsto assert the request body schema'srequiredset contains the expected parameters. Verified the assertion fails when the fix is reverted.Sample Request(s)
GET /api/openapi— request body schema component for a stored procedure with parameterstitle,publisher_name(neither having a default):