fix(openapi): don't apply the global name converter to the generated document#8360
Merged
Merged
Conversation
3 tasks
…document PR api-platform#8306 wired serializer.name_converter.metadata_aware into the OpenAPI serializer to honor #[SerializedName('$ref')] on Reference. That service carries framework.serializer.name_converter as its fallback, so a globally configured converter (e.g. camelCase_to_snake_case) leaked into the spec, producing keys like operation_id, extension_properties, request_bodies that break openapi-generator-cli. Use a dedicated MetadataAwareNameConverter with no fallback: SerializedName metadata is still honored, the global converter no longer applies.
60f66c6 to
62d033e
Compare
soyuka
commented
Jun 29, 2026
Co-authored-by: Antoine Bluchet <soyuka@users.noreply.github.com>
Contributor
|
Fix confirmed, thanks!! |
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.
Problem
#8306 fixed
Referenceserialization ($ref) by wiringserializer.mapping.class_metadata_factoryandserializer.name_converter.metadata_awareinto the OpenAPI serializer's inlineObjectNormalizer, so that#[SerializedName('$ref')]onReference::getRef()is honored.Side effect (reported by @thomas-hiron in #8306):
serializer.name_converter.metadata_awarecarriesframework.serializer.name_converteras its fallback converter (seeFrameworkExtension, which sets argument 1 of that service to the configured name converter). So a project configured with:now gets the whole OpenAPI document run through that converter, producing snake_case keys:
operation_id,extension_properties,request_bodies,security_schemes,authorization_url… which breakopenapi-generator-cli:Fix
Reference::getRef()'s#[SerializedName('$ref')]is the only serialization metadata the OpenAPI models rely on. Use a dedicatedMetadataAwareNameConverterbuilt with the class metadata factory only (no fallback).SerializedNameis still honored; the globally configured converter no longer leaks into the document.Tests
New
tests/Functional/OpenApiNameConverterTest.phpboots a kernel configuring the globalcamelCase_to_snake_caseconverter and asserts:operationId, nooperation_id/extension_properties/request_bodies/security_schemes)#[SerializedName('$ref')]still emits$refVerified failing on the buggy wiring, passing with the fix. Full
OpenApiTest+OpenApiNormalizerTestsuites green (28 tests, 268 assertions).