Skip to content

Error on $ref with path in remote files #779

@MR4online

Description

@MR4online

Hi there!

the following works in openapi-backend 5.11.1:

  • $ref: '#/components/schemas/Test'
  • $ref: './otherFile.yaml'

the following does not work:

  • $ref: './otherFile.yaml/#/components/schemas/Test'

See OpenAPI reference.

The occuring Error Message is:

{
  stack: 'ResolverError: Error opening file "/app/test.yaml/" \n' +
    "ENOTDIR: not a directory, open '/app/test.yaml/'\n" +
    '    at Object.read (/app/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/resolvers/file.js:71:19)',
  code: 'ERESOLVER',
  name: 'ResolverError',
  message: 'Error opening file "/app/test.yaml/" \n' +
    "ENOTDIR: not a directory, open '/app/test.yaml/'",
  source: '/app/test.yaml/',
  path: null,
  toJSON: [Function: toJSON],
  ioErrorCode: 'ENOTDIR',
  footprint: 'null+/app/test.yaml/+ERESOLVER+Error opening file "/app/test.yaml/" \n' +
    "ENOTDIR: not a directory, open '/app/test.yaml/'",
  toString: [Function: toString]
}

 /app/node_modules/openapi-backend/backend.js:411
             const securitySchemes = ((_a = this.definition.components) === null || _a === void 0 ? void 0 : _a.securitySchemes) || {};
                                                            ^
 
 TypeError: Cannot read properties of undefined (reading 'components')
     at OpenAPIBackend.registerSecurityHandler (/app/node_modules/openapi-backend/backend.js:411:60)
     at OpenAPIBackend.init (/app/node_modules/openapi-backend/backend.js:184:26)
     at async file:///app/src/index.ts:69:1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions