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

Change ordering of actions #1961

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Conversation

prmshepherd
Copy link

Update the ordering of the actions as the one literal on default option is not working for descriminator properties

Update the ordering of the actions as the one literal on default option is not working for descriminator properties
Copy link

codecov bot commented Jun 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (main@8c6dbd3). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1961   +/-   ##
=======================================
  Coverage        ?   98.80%           
=======================================
  Files           ?       37           
  Lines           ?     4195           
  Branches        ?      976           
=======================================
  Hits            ?     4145           
  Misses          ?       31           
  Partials        ?       19           
Flag Coverage Δ
unittests 98.49% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

codspeed-hq bot commented Jun 1, 2024

CodSpeed Performance Report

Merging #1961 will not alter performance

Comparing prmshepherd:main (57a519f) with main (8c6dbd3)

Summary

✅ 29 untouched benchmarks

@koxudaxi
Copy link
Owner

koxudaxi commented Jun 5, 2024

@prmshepherd
Sorry for my late response.
Thank you for creating the PR.
Could you please provide the test case?
I would like to add the unittest for the changes.

@prmshepherd
Copy link
Author

Hi @koxudaxi, sorry I have this in draft as more work is needed by me. My use-case is when I am using a discriminator

openapi: 3.0.0
info:
  title: Pet API
  version: 1.0.0
paths:
  /pets:
    post:
      summary: Add a new pet
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Pet'
      responses:
        '200':
          description: Successfully added the pet
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Pet'
components:
  schemas:
    Pet:
      type: object
      oneOf:
       - $ref: '#/components/schemas/Dog'
       - $ref: '#/components/schemas/Cat'
      discriminator:
        propertyName: petType
        mapping:
          dog: '#/components/schemas/Dog'
          cat: '#/components/schemas/Cat'
    Dog:
      properties:
        breed:
          type: string
        barkVolume:
          type: integer
          format: int32
          description: The volume of the dog's bark
    Cat:
      properties:
        color:
          type: string
        isIndoor:
          type: boolean
          description: Indicates if the cat is an indoor cat

This generates:

class Dog(BaseModel):
    breed: Optional[str] = None
    barkVolume: Optional[int] = Field(None, description="The volume of the dog's bark")
    petType: Literal['dog']

What I would like is petType: Literal['dog'] = 'dog'.

But I think the ordering of those actions prevents that

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.

None yet

2 participants