Skip to content

Cleanup OpenAPI handling of primitive formats - #68082

Merged
Youssef1313 merged 1 commit into
mainfrom
dev/ygerges/cleanup-openapi
Aug 1, 2026
Merged

Youssef1313 merged 1 commit into
mainfrom
dev/ygerges/cleanup-openapi

Conversation

@Youssef1313

Copy link
Copy Markdown
Member

This code only needs to decide the OpenApiSchema.Format to use.

  • The schema id part is already applied in ApplySchemaReferenceId call that happens right after ApplyPrimitiveFormats. So there is no need for ApplyPrimitiveFormats to do anything there.
  • The JsonSchemaType should be correctly set by STJ. We don't need anything special there as well.
  • The nullability handling became a dead code. It in the past used to set nullable: true (before OpenAPI 3.1+ support). But now that we are setting only Type, it's irrelevant and STJ should get us the right thing already (if needed)

This PR should have no behavior changes, and is only a cleanup.

Copilot AI review requested due to automatic review settings July 29, 2026 10:55
@Youssef1313
Youssef1313 requested a review from a team as a code owner July 29, 2026 10:55

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

Refactors OpenAPI schema post-processing so primitive handling only applies OpenApiSchema.Format, relying on existing schema-id and type/nullability logic elsewhere (as intended per the PR description).

Changes:

  • Replace ApplyPrimitiveTypesAndFormats(...) with ApplyPrimitiveFormats(...) and update the call site.
  • Simplify the primitive mapping from Type -> OpenApiSchema to Type -> format string, removing unrelated schema mutations.

Reviewed changes

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

File Description
src/OpenApi/src/Services/Schemas/OpenApiSchemaService.cs Updates schema generation pipeline to call the new ApplyPrimitiveFormats helper before schema-id application.
src/OpenApi/src/Extensions/JsonNodeSchemaExtensions.cs Renames/simplifies primitive handling to apply only known format values via a Type -> string map and trims dead logic.
Comments suppressed due to low confidence (1)

src/OpenApi/src/Extensions/JsonNodeSchemaExtensions.cs:204

  • The XML doc comment has a duplicated word (“it is is”), which reads as a typo.
    /// Note that this method targets <see cref="JsonNode"/> and not <see cref="OpenApiSchema"/> because
    /// it is is designed to be invoked via the `OnGenerated` callback in the underlying schema generator as
    /// opposed to after the generated schemas have been mapped to OpenAPI schemas.

@Youssef1313
Youssef1313 merged commit 87bea93 into main Aug 1, 2026
27 checks passed
@Youssef1313
Youssef1313 deleted the dev/ygerges/cleanup-openapi branch August 1, 2026 09:56
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-rc1 milestone Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants