Skip to content

Mark stored procedure parameters without defaults as required in OpenAPI#3687

Open
souvikghosh04 with Copilot wants to merge 7 commits into
mainfrom
copilot/fix-openapi-required-params
Open

Mark stored procedure parameters without defaults as required in OpenAPI#3687
souvikghosh04 with Copilot wants to merge 7 commits into
mainfrom
copilot/fix-openapi-required-params

Conversation

Copilot AI commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Why make this change?

  • Closes [Bug]: Required params not marked in OpenAPI #3498. The generated OpenAPI document for stored procedure entities omitted the required array on the {entity}_sp_request schema, 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 config required: true populated the array, which is almost never set, so the array was always empty.
    • Mirrors the existing IsRequestBodyRequired logic (!HasConfigDefault), keeping body-level and property-level required semantics consistent. An explicit config required: false is still honored.
if (def.Required ?? !def.HasConfigDefault)
{
    required.Add(parameter);
}

How was this tested?

  • Integration Tests
  • Unit Tests

Extended StoredProcedureGeneration.ValidateRequestBodyContents to assert the request body schema's required set 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 parameters title, publisher_name (neither having a default):

"sp1_sp_request": {
  "type": "object",
  "properties": {
    "title": { "type": "string" },
    "publisher_name": { "type": "string" }
  },
  "required": [ "title", "publisher_name" ]
}

Copilot AI changed the title [WIP] Fix required params not marked in OpenAPI schema Mark stored procedure parameters without defaults as required in OpenAPI Jun 26, 2026
Copilot AI requested a review from souvikghosh04 June 26, 2026 08:24
@souvikghosh04

Copy link
Copy Markdown
Contributor

@copilot please add tests from to support the changes

Copilot AI commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please add tests from to support the changes

Added tests in StoredProcedureGeneration.ValidateRequestBodyContents covering all branches of the required-parameter logic:

  • sp1: parameters without defaults are all required.
  • sp2 (insert_book): a parameter with a config-provided default is not required.
  • sp3 (update_book_title): a parameter explicitly marked required: false is not required.

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)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 == true or when Required is unset and no config default exists.
  • Extend OpenAPI integration tests to validate the schema component’s required parameters 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.

Comment thread src/Service.Tests/OpenApiDocumentor/StoredProcedureGeneration.cs Outdated
Comment thread src/Core/Services/OpenAPI/OpenApiDocumentor.cs

@RubenCerna2079 RubenCerna2079 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Approving assuming comments from myself and copilot are resolved.

Comment thread src/Service.Tests/OpenApiDocumentor/StoredProcedureGeneration.cs Outdated
souvikghosh04 and others added 2 commits July 9, 2026 15:58
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: RubenCerna2079 <32799214+RubenCerna2079@users.noreply.github.com>
@souvikghosh04 souvikghosh04 enabled auto-merge (squash) July 9, 2026 10:37
@souvikghosh04

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 6 pipeline(s).

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

Labels

None yet

Projects

Status: Review In Progress

Development

Successfully merging this pull request may close these issues.

[Bug]: Required params not marked in OpenAPI

6 participants