openapi-backend icon indicating copy to clipboard operation
openapi-backend copied to clipboard

Error on $ref with path in remote files

Open MR4online opened this issue 11 months ago • 0 comments

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

MR4online avatar Mar 04 '25 10:03 MR4online