Closed amnuts closed 3 years ago
have you called resolveReferences()
method on the base object after reading the file?
I'm having a similar issue. If I define a path that contains an x-* attribute without using a reference then:
$spec->paths['path']->{'x-*'}
contains the value of the x-* attribute. However, if the path only contains:
$ref: 'filename.yaml'
where filename.yaml has the x-attribute defined, then:
$spec->paths['path']->{'x-*'}
throws the exception: Exception: Getting unknown property: cebe\openapi\spec\PathItem::x-*
I've worked around it for the moment in an odd way, if I define the path so that the x- attribute is in the paths spec, followed by the $ref attribute, then I'm able to access the x- property as expected. More specifically this works:
paths:
'path':
x-*: 'value'
$ref: 'filename.yaml'
and this doesn't:
paths:
'path':
$ref: 'filename.yaml' # where x-* is a root element of filename.yaml
I'm unsure if this is clear enough, and if it is the same issue. If you need a working example, I can probably put it together.
Reproduced, added a failing test case in #111. If someone wants to dig into fixing this, I'd be happy to merge a fix. Have no time to fix it myself right now.
I'm using x-* extensions in a number of places and wanted to split up my OAS doc over multiple files. If I have a
x-subscription
content inline in the main file at root level, like this:Then after I do
$specs = Reader::readFromJsonFile(realpath($specPath));
I can access the subscriptions, egvar_dump($spec->{'x-subscriptions'});
gives me:But if I have:
with the full array moved to another file, the same
$spec
calls returns:I've tried a variety of ways (using 'allOf', having the array be in the root and reference individual events, etc.) but the reference doesn't resolve.
So I guess my question is; should it?
Thanks!