Closed niklas-e closed 4 years ago
@niklas-e - The $ref
paths are relative to the file that they appear in, not to the root file. So #/components/schemas/Error
is an invalid path in responses.yaml
. You need to point to the path in api.yaml
instead, like this:
401:
description: Unauthorized
content:
application/json:
schema:
$ref: "api.yaml#/components/schemas/Error"
Yeah, I somehow missed that from the docs. Probably got misled because it actually seemed to work with different parser. Thanks for your response.
I'm using swagger-cli, which seems to use this library for validation and bundling. I made an OAS 3 definition with
Error
schema under components and then added$ref: '#/components/schemas/Error'
to my response definitions which are in a separate file. This causes the following error on validation:Here's a sample which is sufficient to reproduce the error.
responses.yaml
api.yaml
I also noticed this same behavior occurs when referring to other schemas inside a schema (when the schemas are in separate files).