Skip to content

References to incorrect components should be considered invalid #171

Open
@charjr

Description

@charjr

Expected

Referencing a component that does not meet the criteria an object requires should be considered invalid.

Example

A Response object referencing a component that does not contain a "description" should be considered invalid.

image

Reasoning

"description" is a REQUIRED property for a Response object.

Actual

Referencing a component that does not meet the criteria an object requires is considered valid.

Example

$api = Reader::readFromJson(<<<JSON
{
  "openapi": "3.0.0",
  "info": {
    "title": "Test API",
    "version": "1.0.0"
  },
  "paths": {
    "/path": {
      "get": {
        "responses": {
          "200": {
            "\$ref": "#/components/schemas/notAResponse"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "notAResponse": {
        "type": "integer"
      }
    }
  }
}
JSON);

var_dump($api->validate()); // bool(true)

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