Skip to content

anyOf fails when config enabled but discriminator not defined #588

@sat-bhandal

Description

@sat-bhandal

I am looking to add discriminators to my new schemas. The old schemas will not continue to not include them. If I enable openAPI3StyleDiscriminators, my old schemas which contain anyOf then fail validation.

Is it expected behaviour that if discriminator use is configured that discriminators must be used in schemas?

This may be replicated by appending the following to discriminator.json then running OpenAPI30JsonSchemaTest:

  {
       "description": "absent discriminator definition - anyOf integer/string",
       "schema": {
           "type": "object",
           "properties": {
               "intOrStringType": {
                   "anyOf": [
                       {
                           "type": "integer"
                       },
                       {
                           "type": "string"
                       }
                   ]
               }
           }
       },
       "tests": [
           {
               "description": "does not fallback to default anyOf behaviour - 'should be valid to any of the schemas string'",
               "data": {
                   "intOrStringType": 4
               },
               "valid": true
           }
       ]
   }

@FWiesner perhaps you may be able to advise whether I am misusing the feature?

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions