Skip to content

Preview doesn't open (both swagger and redoc) when referencing other files while specifying type #248

@sebastian-fredriksson-bernholtz

Description

VSCode 1.84.2 on MAC
OpenAPI Editor v4.18.6

I've been having some issues where the preview doesn't open (both swagger and redoc). After doing some investigation I have found that the issue seems to occur when all of the following conditions are true.

  1. one of my schemas references another file
  2. the schema specifies type in addition to the reference to the other file (don't ask me why, someone else wrote it)
  3. the other file in it's turn has a reference to a third file

If 1 doesn't hold true, and I inline the schema from the other file, I get YAML syntax error for duplicate keys and the preview won't open, so I wonder if it's just invalid syntax even when I use a ref and "override" the type. However, since I only have a problem if 3 holds true, not just 1 and 2, it seems like it's supposed to be supported?

I've created a repro here.

These are some logs that I got in VSCode that I think are related:

2023-11-23 00:17:39.908 [error] Error: Unexpected exception while bundling: Error: Error resolving $ref pointer "file:///Users/seb/development/reproductions/openapi/External2.yml". 
"file:///Users/seb/development/reproductions/openapi/External2.yml" not found.
    at /Users/seb/.vscode/extensions/42crunch.vscode-openapi-4.18.6/out/bundler.js:235:23
    at Generator.throw (<anonymous>)
    at rejected (/Users/seb/.vscode/extensions/42crunch.vscode-openapi-4.18.6/out/bundler.js:29:65)
2023-11-23 00:17:39.930 [error] TypeError: Cannot read properties of undefined (reading '0')
    at t.GitService.getRootRepo (/Users/seb/.vscode/extensions/codium.codium-0.7.17/dist/extension.js:2:990217)
    at t.GitService.initialize (/Users/seb/.vscode/extensions/codium.codium-0.7.17/dist/extension.js:2:989020)
    at runNextTicks (node:internal/process/task_queues:60:5)
    at listOnTimeout (node:internal/timers:538:9)
    at processTimers (node:internal/timers:512:7)
    at m.activate (/Users/seb/.vscode/extensions/codium.codium-0.7.17/dist/extension.js:2:869601)
2023-11-23 00:18:04.052 [error] Error: Unexpected exception while bundling: Error: Error resolving $ref pointer "file:///Users/seb/development/reproductions/openapi/External2.yml". 
"file:///Users/seb/development/reproductions/openapi/External2.yml" not found.
    at /Users/seb/.vscode/extensions/42crunch.vscode-openapi-4.18.6/out/bundler.js:235:23
    at Generator.throw (<anonymous>)
    at rejected (/Users/seb/.vscode/extensions/42crunch.vscode-openapi-4.18.6/out/bundler.js:29:65)
2023-11-23 00:18:05.066 [error] Error: Unexpected exception while bundling: Error: Error resolving $ref pointer "file:///Users/seb/development/reproductions/openapi/External2.yml". 
"file:///Users/seb/development/reproductions/openapi/External2.yml" not found.
    at /Users/seb/.vscode/extensions/42crunch.vscode-openapi-4.18.6/out/bundler.js:235:23
    at Generator.throw (<anonymous>)
    at rejected (/Users/seb/.vscode/extensions/42crunch.vscode-openapi-4.18.6/out/bundler.js:29:65)
2023-11-23 00:18:29.893 [error] Error: Unexpected exception while bundling: Error: Error resolving $ref pointer "file:///Users/seb/development/reproductions/openapi/External2.yml". 
"file:///Users/seb/development/reproductions/openapi/External2.yml" not found.
    at /Users/seb/.vscode/extensions/42crunch.vscode-openapi-4.18.6/out/bundler.js:235:23
    at Generator.throw (<anonymous>)
    at rejected (/Users/seb/.vscode/extensions/42crunch.vscode-openapi-4.18.6/out/bundler.js:29:65)
    at runNextTicks (node:internal/process/task_queues:60:5)
    at listOnTimeout (node:internal/timers:538:9)
    at processTimers (node:internal/timers:512:7)

Of note is that the file url (file:///Users/seb/development/reproductions/openapi/External2.yml) is actually incorrect here and that file does not exist. It looks like it's resolved the relative path relative to the entrypoint openapi file, not to the other referenced file that references this third file. Keep in mind though that everything is working correctly if 2 above is not true.

If I change the reference in the "other" file to be relative to the entrypoint openapi file, I still get the same error, even though the file url mentioned is now correct and the file does exist.

2023-11-23 00:56:52.186 [error] Error: Unexpected exception while bundling: Error: Error resolving $ref pointer "file:///Users/seb/development/reproductions/openapi/models/External2.yml". 
"file:///Users/seb/development/reproductions/openapi/models/External2.yml" not found.
    at /Users/seb/.vscode/extensions/42crunch.vscode-openapi-4.18.6/out/bundler.js:235:23
    at Generator.throw (<anonymous>)
    at rejected (/Users/seb/.vscode/extensions/42crunch.vscode-openapi-4.18.6/out/bundler.js:29:65)
2023-11-23 00:56:54.559 [error] Error: Unexpected exception while bundling: Error: Error resolving $ref pointer "file:///Users/seb/development/reproductions/openapi/models/External2.yml". 
"file:///Users/seb/development/reproductions/openapi/models/External2.yml" not found.
    at /Users/seb/.vscode/extensions/42crunch.vscode-openapi-4.18.6/out/bundler.js:235:23
    at Generator.throw (<anonymous>)
    at rejected (/Users/seb/.vscode/extensions/42crunch.vscode-openapi-4.18.6/out/bundler.js:29:65)

As final note, I do have quite a lot of extensions, don't know if it's possible another extension would be interfering?

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