OASValidation policy returns validation loop error with discriminators and allOf

Hello! I am using the OASValidation policy in apigee and getting a strange error when I use a discriminator. When using an open api schema such as this:

 

components:
  schemas:
    Request:
      type: object
      description: "description"
      properties:
        metadata:
          $ref: '#/components/schemas/Metadata'
    Metadata:
      type: object
      description: 'description'
      discriminator:
        propertyName: pet_type
        mapping:
          Cat: "#/components/schemas/CatMetadata"
          Dog: "#/components/schemas/DogMetadata"
      properties:
        pet_type:
          type: string
          enum:
            - Cat
            - Dog
          description: 'The type of pet'
          example: Cat
      required:
        - pet_type
    CatMetadata:
      allOf:
        - $ref: '#/components/schemas/Metadata'
        - type: object
          properties:
            name:
              type: string
              description: 'Name of pet'
          required:
            - name
    DogMetadata:
      allOf:
        - $ref: '#/components/schemas/Metadata'
        - type: object
          properties:
            name:
              type: string
              description: 'Name of pet'
          required:
            - name

 

And submitting a payload such as this:

 

{
  "metadata": {
    "pet_type": "Cat",
    "name": "Fluffy"
  }
}

 

I am receiving an error similar to:

 

{
  "title": "OAS Validation Failure",
  "type": "OAS Validation Failure",
  "status": "400",
  "detail": "Request failed validation against the API specification.",
  "instance": "/path",
  "source": [
    {
      "detail": "ERROR - [Path '/metadata'] Validation loop: schema \"#/components/schemas/CatMetadata\" visited twice for pointer \"/metadata\" of validated instance: []"
    }
  ]
}

 

Does anyone have guidance to workaround such an issue? Does OASValidation not support discriminators for open api spec version 3.0.1?

 

1 0 153
0 REPLIES 0