Omit redundant _NoAutoPK and _NoPK OpenAPI schemas when request-body-strict is false#3325
Omit redundant _NoAutoPK and _NoPK OpenAPI schemas when request-body-strict is false#3325aaronburtle wants to merge 5 commits intomainfrom
Conversation
There was a problem hiding this comment.
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.IsRequestBodyStrictinto path/operation generation so request body schema refs can vary by strictness. - Skips generating
_NoAutoPK/_NoPKcomponent schemas whenrequest-body-strictis 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. |
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
|
@copilot can you please review again |
Both previously flagged issues have been addressed in the existing commits:
The implementation is complete and no further changes are needed. |
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
isRequestBodyStrictflag is now threaded throughBuildPathsandCreateOperationsso that POST/PUT/PATCH request body schema references point to the base entity schema when strict mode is off. TheCreateComponentSchemasmethod now gates_NoAutoPKand_NoPKschema generation on strict mode, and its XML documentation has been updated to accurately describe both strict and non-strict behavior.How was this tested?
Updated existing unit test
RequestBodyStrict_False_OmitsRedundantSchemas(renamed fromRequestBodyStrict_False_AllowsExtraFields) to verify that when request-body-strict is false:_NoAutoPKand_NoPKcomponent schemas are not generated._NoAutoPKor_NoPK).📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.