Skip to content

OpenAPIParser::SchemaValidator.validate ignores type/$ref in additionalProperties #186

@kbarry-aurora

Description

@kbarry-aurora

Also see https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.0.md#model-with-mapdictionary-properties.

Example:

spec = <<~YAML
  openapi: 3.0.0
  components:
    schemas:
      Object:
        type: object
        additionalProperties:
          type: string
YAML
payload = {
  "abc" => "123",
  "def" => 456
}
schemas = OpenAPIParser.parse(
  YAML.load(spec),
  strict_reference_validation: true
).components.schemas

### This should raise an exception due to "def" not being a string. ###
OpenAPIParser::SchemaValidator.validate(
  payload,
  schemas["Object"],
  OpenAPIParser::SchemaValidator::Options.new(coerce_value: false)
)

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions