Skip to content

Unmarshalling not working properly when the root does not have type: object #401

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

Closed
Wim-De-Clercq opened this issue Aug 29, 2022 · 2 comments
Labels
area/unmarshalling Indicates an issue on unmarshalling area. kind/enhancement

Comments

@Wim-De-Clercq
Copy link
Contributor

Wim-De-Clercq commented Aug 29, 2022

Please see 3f82148 for a failing testcase.

The docs (https://swagger.io/docs/specification/data-models/oneof-anyof-allof-not/#allof) have examples like

    Dog:     # "Dog" is a value for the pet_type property (the discriminator value)
      allOf: # Combines the main `Pet` schema with `Dog`-specific properties 
        - $ref: '#/components/schemas/Pet'
        - type: object
          # all other properties specific to a `Dog`
          properties:
            bark:
              type: boolean
            breed:
              type: string
              enum: [Dingo, Husky, Retriever, Shepherd]
    Cat:     # "Cat" is a value for the pet_type property (the discriminator value)
      allOf: # Combines the main `Pet` schema with `Cat`-specific properties 
        - $ref: '#/components/schemas/Pet'
        - type: object
          # all other properties specific to a `Cat`
          properties:
            hunts:
              type: boolean
            age:
              type: integer

So just a schema with allOf, no type: object.
But using such a schema causes some unmarshalling to be skipped, as a date/datetime string would remain a string after spec_validate_body instead of being parsed.

When type: object is used, (like the comment in the yaml in the commit) then the test case succeeds.

@Wim-De-Clercq Wim-De-Clercq changed the title Unmarshalling not working propery when the root does not have type: object Unmarshalling not working properly when the root does not have type: object Aug 29, 2022
@p1c2u
Copy link
Collaborator

p1c2u commented Oct 2, 2022

Unmarshalling mechanism is very simple for now. It determines the type based on top level schema (no allof, anyfo, oneof are taken under consideration)

@p1c2u p1c2u added kind/enhancement area/unmarshalling Indicates an issue on unmarshalling area. labels Dec 20, 2022
@p1c2u
Copy link
Collaborator

p1c2u commented Dec 21, 2022

This should be resolved with the latest unmarshaller finders refactor

@p1c2u p1c2u closed this as completed Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/unmarshalling Indicates an issue on unmarshalling area. kind/enhancement
Projects
None yet
Development

No branches or pull requests

2 participants