Repository navigation
Cleanup OpenAPI handling of primitive formats - #68082
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
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(...)withApplyPrimitiveFormats(...)and update the call site. - Simplify the primitive mapping from
Type -> OpenApiSchematoType -> 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.
halter73
approved these changes
Jul 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This code only needs to decide the
OpenApiSchema.Formatto use.ApplySchemaReferenceIdcall that happens right afterApplyPrimitiveFormats. So there is no need forApplyPrimitiveFormatsto do anything there.JsonSchemaTypeshould be correctly set by STJ. We don't need anything special there as well.nullable: true(before OpenAPI 3.1+ support). But now that we are setting onlyType, 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.