cebe / php-openapi

Read and write OpenAPI yaml/json files and make the content accessible in PHP objects.
MIT License
466 stars 88 forks source link

Cannot use reference to component referenced from external file. #54

Closed liquorvicar closed 4 years ago

liquorvicar commented 4 years ago

If I have defined a component externally, like this:

components:
  schemas:
    Pet:
      $ref: definitions.yaml#/Pet

Then I expect to be able to use it like this:

paths:
  '/pet':
    get:
      responses:
        200:
          description: return a pet
          content:
            'application/json':
              schema:
                $ref: "#/components/schemas/Pet"

However, when I do so, I get an error: cebe\openapi\exceptions\UnresolvableReferenceException : Cyclic reference detected, setReferenceContext() called on a Reference Object.

liquorvicar commented 4 years ago

I think https://swagger.io/docs/specification/components/ -> "Externally Defined Components" documents the behaviour I am talking about.

I am not very familiar with this code base but am happy to have a crack at fixing this if you need (as long as you can give me some pointers!)

cebe commented 4 years ago

I think this is a duplicate of #57 could you please try with current dev-master if this fixes it?

cebe commented 4 years ago

added a test to verify it is fixed by #57

andy-educake commented 4 years ago

Yep, I can confirm it's fixed at our end. Many thanks!