cebe / cebe/php-openapi

References to incorrect components should be considered invalid

Open
#171 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
500
Forks
99
PR merge metrics
No merged PRs in 30d

Description

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)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Reader::readFromJson example and the $api->validate() call, then trace how the response $ref is resolved and validated against the referenced component. Add a regression case for a response referencing an invalid schema component; done means validation rejects the example instead of returning true.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.