Properties not detected by validator when composed with allOf

Issue #45 closed
Matt Smith created an issue

I ran into this issue when attempting to re-use a definition for properties but give them different descriptions:

{
  ...
  "paths" : {
    "/" : {
      "post": {
        "summary": "broken allOf demo",
        "parameters" : [ {
          "in" : "body",
          "name" : "body",
          "schema" : {
            "$ref" : "#/definitions/Thing"
          }
        } ],
        "responses": { "200": { "description": "OK" } }
      }
    }
  },

  "definitions" : {
    "Thing" : {
      "required" : [ "foo" ],
      "properties" : {
        "foo" : {
          "allOf": [
            { "description" : "Descriptive description describing foo" },
            { "$ref" : "#/definitions/hex" }
          ]
        }
      }
    },
    "hex" : {
      "type" : "string",
      "pattern": "^(0x)?[a-fA-F0-9]*$"
    }
  }
}

When I execute a test against this schema, the validator's swaggerDefinition.definitions object's entry for Thing is missing the foo property and I get the error message: Object instance has properties which are not allowed by the schema: ["foo"].

I don't get an error when constructing the schema, the property is just silently ignored.

Comments (6)

  1. Tuan Dinh

    Hi,

    Did you try to add this

                     .withLevelResolver(
                            LevelResolver.create()
                            .withLevel("validation.schema.additionalProperties", ValidationReport.Level.IGNORE)
                            .build())
    

    as suggested in the project's README.md ?

    And assuming the missing "," between "required" : ["foo"] and "properties"... is just a type...

  2. Matt Smith reporter

    Yeah, the missing comma was just a typo. I hadn't seen that note in the README, it's probably the same issue – I'll check and confirm.

  3. James Navin

    Hi @imthedoctor - as @tvdinh mentioned this looks like a known problem with using additionalProperties and allOf.

    If you can confirm I'll close the ticket.

    Cheers.

  4. Matt Smith reporter

    Hey guys, I confirmed this is the known issue. Thanks for the help, go ahead and close this out!

  5. Log in to comment