openapi_parser icon indicating copy to clipboard operation
openapi_parser copied to clipboard

support schemas validation in additionalProperties + remove additionalProperties logic from allof

Open epaillous opened this issue 1 year ago • 0 comments

Description

For now, when passing schemas like :

  type: object
  required:
    - head_count
  properties:
    head_count:
      type: integer
      format: int64
    mass:
      type: integer
  additionalProperties:
    type: string  

there is no error triggered on value like :

{
  "color"       => "gold",
  "head_count" => 20,
  "speed"      => 20
}

because the gem does not support validating schemas inside additionalProperties field. This PR intends to support this behaviour.

While implementing this PR, some specs in all_of_validator_spec were failing (or not failing) because of some combination of subschemas in allOf having additionalProperties to false. But according to OpenApi specification, "allOf takes an array of object definitions that are validated independently but together compose a single object.", meaning validating allOf schemas should be equivalent to validating each schema one by one. So there is no reason to check remainingKeys in AllOfValidator object.

Let me know if you need anything else 😇

epaillous avatar May 02 '24 16:05 epaillous