-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
[scala-sttp4] Circe codecs do not preserve original JSON property names #24681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
wing328
merged 1 commit into
OpenAPITools:master
from
vivekmahajan:fix/scala-sttp4-circe-basename-codecs
Aug 13, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
94 changes: 94 additions & 0 deletions
94
modules/openapi-generator/src/test/resources/3_0/scala/sttp4-mixed-case-fields.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| openapi: 3.0.0 | ||
| info: | ||
| title: sttp4 mixed case fields | ||
| version: 1.0.0 | ||
| paths: | ||
| /bookings: | ||
| post: | ||
| operationId: createBooking | ||
| requestBody: | ||
| content: | ||
| application/json: | ||
| schema: | ||
| $ref: '#/components/schemas/MixedCaseModel' | ||
| responses: | ||
| '200': | ||
| description: OK | ||
| content: | ||
| application/json: | ||
| schema: | ||
| $ref: '#/components/schemas/PaymentMethod' | ||
| components: | ||
| schemas: | ||
| MixedCaseModel: | ||
| type: object | ||
| required: | ||
| - assignment_key | ||
| properties: | ||
| assignment_key: | ||
| type: string | ||
| first-name: | ||
| type: string | ||
| phone_number: | ||
| type: string | ||
| lastName: | ||
| type: string | ||
| ZipCode: | ||
| type: string | ||
| address_line_2: | ||
| type: string | ||
| trip_summary: | ||
| $ref: '#/components/schemas/TripSummary' | ||
| booking_status: | ||
| type: string | ||
| enum: | ||
| - pending | ||
| - confirmed | ||
| TripSummary: | ||
| type: object | ||
| properties: | ||
| departure_airport_code: | ||
| type: string | ||
| PaymentMethod: | ||
| oneOf: | ||
| - $ref: '#/components/schemas/CreditCardPayment' | ||
| - $ref: '#/components/schemas/BankTransferPayment' | ||
| discriminator: | ||
| propertyName: payment_type | ||
| mapping: | ||
| credit_card: '#/components/schemas/CreditCardPayment' | ||
| bank_transfer: '#/components/schemas/BankTransferPayment' | ||
| CreditCardPayment: | ||
| type: object | ||
| required: | ||
| - card_holder_name | ||
| properties: | ||
| payment_type: | ||
| type: string | ||
| card_holder_name: | ||
| type: string | ||
| last-four-digits: | ||
| type: string | ||
| BankTransferPayment: | ||
| type: object | ||
| properties: | ||
| payment_type: | ||
| type: string | ||
| account_holder_name: | ||
| type: string | ||
| Shape: | ||
| oneOf: | ||
| - $ref: '#/components/schemas/Circle' | ||
| - $ref: '#/components/schemas/Square' | ||
| Circle: | ||
| type: object | ||
| required: | ||
| - radius_cm | ||
| properties: | ||
| radius_cm: | ||
| type: number | ||
| Square: | ||
| type: object | ||
| properties: | ||
| side_length: | ||
| type: number |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: Inline (exclusive) oneOf members get a new explicit decoder that references enum properties with the raw
{{dataType}}instead of the enum-aware type ({{classname}}Enums.{{datatypeWithEnum}}) that the regular-model codecs in this same change use. If an exclusive oneOf member carries an enum-typed property, it won't be decoded/validated through the generated enum type and may not even reference a resolvable type, unlike every regular model. For consistency with the rest of this PR, the inline-member decoder (and its case-class field type) should apply the same{{#isEnum}}...{{classname}}Enums.{{datatypeWithEnum}}...{{/isEnum}}mapping used for regular models.Prompt for AI agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not introduced here, and the narrow version of this fix would break the build.
The inline-member case class already uses raw
{{dataType}}on master — this PR doesn't touch that line:So the new decoder deliberately mirrors the field it has to construct. Changing only the decoder to
{{classname}}Enums.{{datatypeWithEnum}}would make the two disagree and fail to compile.Changing both wouldn't work either: the
object {{classname}}Enumswrapper is only emitted in thex-isRegularModelbranch, so it doesn't exist for inlineoneOfmembers. For this spec:master and this branch both generate
buttonState: Option[String]with noClickEventEnumsobject anywhere. Typed enums on inlineoneOfmembers simply aren't supported yet — a pre-existing gap, and adding that support means emitting the enums object in the sealed-trait branch too, which is out of scope for a codec-naming fix.Verified the generated client for the spec above compiles on this branch.