Skip to content

The property '#/.../patternProperties/required' of type TrueClass did not match the following type: object #29

Description

@phs

Consider this minimal reproducing endpoint:

---
name: url
route: /url
method: PUT
definitions:
  - message_type: request
    versions: ["0.1"]
    schema:
      type: object
      patternProperties:
        '^[^:\s]+$':
          type: string
    examples:
      - "Server": "nginx"
  - message_type: response
    versions: ["0.1"]
    status_codes: ["2xx"]
    schema: {}
    examples: []

The request schema itself does not validate, which manifests when trying to validate the examples:

  1) MozLinks::Apps::API url (v 0.1) has valid data for example 1
     Failure/Error: define_test(description) { example.validate! }
     Interpol::ValidationError:
       Found 1 error(s) when validating against endpoint url (request v. 0.1). Errors:
         - The property '#/patternProperties/required' of type TrueClass did not match the following type: object in schema http://json-schema.org/draft-03/schema#.

       Data:
       {"type"=>"object", "patternProperties"=>{"^[^:\\s]+$"=>{"type"=>"string", "required"=>true}, "required"=>true}, "required"=>true}
     # /usr/local/var/rbenv/versions/jruby-1.7.4/lib/ruby/gems/shared/gems/interpol-0.10.2/lib/interpol/endpoint.rb:220:in `validate_data!'

It appears to be complaining about this, in the context of the patternProperties clause.

All keys of a patternProperties must be regexs (strings), but the values must all be schemas (objects.) The true that interpol slips in doesn't conform.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions