Skip to content

Dart: fix wrong property name casing for serialization#6393

Merged
baywet merged 4 commits intomicrosoft:mainfrom
ricardoboss:fixes/preseve-serialization-name-during-refining
Apr 4, 2025
Merged

Dart: fix wrong property name casing for serialization#6393
baywet merged 4 commits intomicrosoft:mainfrom
ricardoboss:fixes/preseve-serialization-name-during-refining

Conversation

@ricardoboss
Copy link
Contributor

@ricardoboss ricardoboss commented Apr 2, 2025

This fixes an issue in the Dart refiner, where property names are adjusted for code style, but their serialized name is also changed by accident.

Example spec
openapi: 3.0.1
info:
  title: Test
  version: 0.0.1

paths:
  /action:
    post:
      summary: Action
      operationId: action
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ActionRequest'
      responses:
        '200':
          description: Action Processed
          content:
            application/json:
              type: object
              additionalProperties: true

components:
  schemas:
    ActionRequest:
      type: object
      properties:
        Token:
          type: string
        type:
          type: string

In the example above, a body serialized by kiota would send it like:

{"token":"foo","type":"bar"}

whereas the expected body is:

{"Token":"foo","type":"bar"}

(notice the capitalized Token, like it is in the spec)

This PR fixes the refiner by storing the serialized name before changing the property name.

@ricardoboss ricardoboss requested a review from a team as a code owner April 2, 2025 18:35
rkodev
rkodev previously approved these changes Apr 4, 2025
@ricardoboss ricardoboss force-pushed the fixes/preseve-serialization-name-during-refining branch from 867ed88 to 48d2a16 Compare April 4, 2025 11:01
baywet
baywet previously approved these changes Apr 4, 2025
Copy link
Member

@baywet baywet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

@baywet baywet dismissed stale reviews from rkodev and themself via 0b93aec April 4, 2025 13:22
@baywet baywet enabled auto-merge (squash) April 4, 2025 13:22
@baywet baywet requested a review from rkodev April 4, 2025 13:22
@baywet baywet merged commit 6c20342 into microsoft:main Apr 4, 2025
286 checks passed
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