Skip to content

Omit redundant _NoAutoPK and _NoPK OpenAPI schemas when request-body-strict is false#3325

Open
aaronburtle wants to merge 5 commits intomainfrom
dev/aaronburtle/fix-request-body-strict-false-open-api
Open

Omit redundant _NoAutoPK and _NoPK OpenAPI schemas when request-body-strict is false#3325
aaronburtle wants to merge 5 commits intomainfrom
dev/aaronburtle/fix-request-body-strict-false-open-api

Conversation

@aaronburtle
Copy link
Copy Markdown
Contributor

@aaronburtle aaronburtle commented Mar 26, 2026

Why make this change?

Closes #3260

What is this change?

When request-body-strict is set to false, the OpenAPI document was still generating separate _NoAutoPK and _NoPK component schemas for each entity. These schemas only differ from the base entity schema by excluding primary key fields, a distinction that is meaningless when the request body already allows additional properties. This made the generated OpenAPI document unnecessarily verbose and confusing for consumers.

The isRequestBodyStrict flag is now threaded through BuildPaths and CreateOperations so that POST/PUT/PATCH request body schema references point to the base entity schema when strict mode is off. The CreateComponentSchemas method now gates _NoAutoPK and _NoPK schema generation on strict mode, and its XML documentation has been updated to accurately describe both strict and non-strict behavior.

How was this tested?

  • Integration Tests
  • Unit Tests

Updated existing unit test RequestBodyStrict_False_OmitsRedundantSchemas (renamed from RequestBodyStrict_False_AllowsExtraFields) to verify that when request-body-strict is false:

  • _NoAutoPK and _NoPK component schemas are not generated.
  • The base entity schema is still present.
  • POST/PUT/PATCH operations reference the base entity schema (not _NoAutoPK or _NoPK).

📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

Copilot AI review requested due to automatic review settings March 26, 2026 14:38
@aaronburtle aaronburtle changed the title fix noAutoPK and NoPK openapidoc Omit redundant _NoAutoPK and _NoPK OpenAPI schemas when request-body-strict is false Mar 26, 2026
@aaronburtle aaronburtle self-assigned this Mar 26, 2026
@aaronburtle aaronburtle added 2.0 bug Something isn't working labels Mar 26, 2026
@aaronburtle aaronburtle moved this from Todo to Review In Progress in Data API builder Mar 26, 2026
@aaronburtle aaronburtle added this to the March 2026 milestone Mar 26, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 document generation to avoid emitting redundant request-body component schemas (_NoAutoPK/_NoPK) when request-body-strict is disabled, reducing OpenAPI verbosity and aligning with the runtime behavior described in issue #3260.

Changes:

  • Plumbs runtimeConfig.IsRequestBodyStrict into path/operation generation so request body schema refs can vary by strictness.
  • Skips generating _NoAutoPK / _NoPK component schemas when request-body-strict is false and instead references the base entity schema.
  • Updates the existing OpenAPI integration test to assert the redundant schemas are not produced in non-strict mode.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/Service.Tests/OpenApiDocumentor/RequestBodyStrictTests.cs Renames/updates the non-strict test to verify _NoAutoPK/_NoPK schemas are omitted and base schema remains.
src/Core/Services/OpenAPI/OpenApiDocumentor.cs Threads request-body strictness into BuildPaths/CreateOperations and gates request-body schema generation on strict mode.

aaronburtle and others added 3 commits March 26, 2026 08:25
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
… of github.com:Azure/data-api-builder into dev/aaronburtle/fix-request-body-strict-false-open-api
@aaronburtle
Copy link
Copy Markdown
Contributor Author

@copilot can you please review again

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 26, 2026

@copilot can you please review again

Both previously flagged issues have been addressed in the existing commits:

  1. Test assertions (commit fc72502): RequestBodyStrict_False_OmitsRedundantSchemas now iterates through all path operations and asserts that POST/PUT/PATCH request bodies reference the base book schema, not book_NoAutoPK/book_NoPK.

  2. XML doc on CreateComponentSchemas (commit afd7ae7): Updated to accurately document that when isRequestBodyStrict is false, only the base {EntityName} schema is created and all request body operations reference it directly.

The implementation is complete and no further changes are needed.

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

Labels

2.0 bug Something isn't working

Projects

Status: Review In Progress

Development

Successfully merging this pull request may close these issues.

[Bug]: when "request-body-strict": false OpenAPI returns "Entity_NoAutoPK" & "Entity_NoPK"

4 participants