Skip to content
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

fix: Deserialize custom types with inline schemas #823

Merged

Conversation

duncanbeevers
Copy link
Contributor

@duncanbeevers duncanbeevers commented Mar 4, 2023

🐸 Problem to be solved

Inline schemas for custom formats in path parameters are not deserialized.

The following simple schema demonstrates the behavior:

  • 🥇 date-in-components is deserialized to a Date object
  • ⚠️ date-inline is not deserialized to a Date object
paths:
  /users
    get:
      parameters:
        - name: date-in-components
          in: query
          schema:
            $ref: '#/components/schemas/DateTime'
        - name: date-inline
          in: query
          schema:
            type: string
            format: date-time
components:
  schemas:
    DateTime:
      type: string
      format: date-time

👑 Proposed solution

Gather path parameter custom-format schemas and augment them in the same way component schemas are.

🔧 Changes

  • serdes.spec app emits summary objects as part of its GET and POST responses
  • Type checks are made against response bodies (as well as existing checks in the endpoint handlers)
  • query parameters declared with inline custom format schemas are deserialized to their expected custom types

@cdimascio cdimascio merged commit d53621d into cdimascio:master Apr 30, 2023
@duncanbeevers duncanbeevers deleted the deserialize-inline-custom-schemas branch April 30, 2023 21:04
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.

2 participants