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

Inner any of type mismatch not raising error #116

Open
Diacrome opened this issue Aug 2, 2023 · 0 comments
Open

Inner any of type mismatch not raising error #116

Diacrome opened this issue Aug 2, 2023 · 0 comments

Comments

@Diacrome
Copy link

Diacrome commented Aug 2, 2023

If we have stacked any of and on the second level send strring, not an object, validator doesn't react.
If we do so on the top any of validator will find error as intended.
python 3.11.2
openapi_schema_validator 0.6.0

Expect error on validation, but there was not.

Object:

        {
            "animals_top_any_of": {
                "milk_product_additional_field": {
                    "product_spec_inner_any_of": "string_not_object_under_any_of_expect_error_but_there_is_not"
                }
            }
        }

Schema:

{
  "type": "object",
  "title": "Farm - top level",
  "allOf": [
    {
      "$ref": "#/components/schemas/Schema"
    }
  ],
  "components":{
    "schemas": {
      "Schema": {
        "properties":{
          "animals_top_any_of": {
            "type": "object",
            "description": "Animals top any Of",
            "anyOf": [
              {
                "$ref": "#/components/schemas/Mammal"
              },
              {
                "$ref": "#/components/schemas/Bird"
              }
            ]
          }
        },
        "required":[
          "animals_top_any_of"
        ]
      },
      "Mammal": {
        "title": "mammal - under to animals_top_any_of",
        "type": "object",
        "properties": {
          "milk_product_additional_field": {
            "$ref": "#/components/schemas/Dairy"
          }
        }
      },
      "Bird": {
        "title": "under animals_top_any_of",
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          }
        }
      },
      "Dairy": {
        "properties": {
          "product_spec_inner_any_of": {
            "type": "object",
            "description": "inner any of",
            "anyOf": [
              {
                "$ref": "#/components/schemas/Milk"
              },
              {
                "$ref": "#/components/schemas/Cream"
              }
            ]
          }
        },
        "required":[
          "product_spec_inner_any_of"
        ]
      },
      "Milk": {
        "title": "milk element inner any of",
        "type": "object",
        "properties": {
          "fat_percentage_int": {
            "type": "integer"
          }
        }
      },
      "Cream": {
        "title": "cream element inner any of",
        "type": "object",
        "properties": {
          "cream_only_viscosity_int": {
            "type": "integer"
          }
        }
      }
    }
  }
}


Top level any of type missmatch works as intended:
object:

            {
                "animals_top_any_of": "string_not_object_under_any_of_correctly_finds_error"
            }
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

No branches or pull requests

1 participant