Skip to content

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

@Wim-De-Clercq

Description

@Wim-De-Clercq

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions