swagger-api / swagger-api/swagger-ui

Resolver error: Could not resolve reference: Could not resolve pointer:

Open
#9,922 3 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

  • OS: macOS
  • Browser: chrome, safari, firefox
  • Version: [e.g. 22]
  • Method of installation: npm
  • Swagger-UI version: > 5.17.2
  • Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration
openapi: 3.0.0
info:
  title: Test API
  description: test spec
  version: 0.0.1
paths:
  /test/v1/endpoint:
    get:
      parameters:
      - $ref: http://localhost:3000/oas/test-domain-v1~0.0.1.yaml#/components/parameters/A
      - $ref: http://localhost:3000/oas/test-domain-v1~0.0.1.yaml#/components/parameters/B
      responses:
        '200':
          description: Success.
          content:
            application/json:
              schema:
                $ref: http://localhost:3000/oas/test-domain-v1~0.0.1.yaml#/components/parameters/A
Describe the bug you're encountering

I have refs retrieved through an API endpoint. They are properly returned and resolved inside the editor. However, swagger-ui has a problem resolving them.
When expanding an operation an error displays:

Resolver error at paths./test/v1/endpoint.get.parameters.0.$ref
Could not resolve reference: Could not resolve pointer: /components/parameters/A does not exist in document
Screenshots

Screenshot 2024-05-07 at 1 15 24 PM

Expected behavior
Additional context or thoughts

Interestingly, when added the reference files to the public folder and referencing them through there, there is no error. However it is undesirable to require a new build every time a ref is modified or added to the referenced file.

Screenshot 2024-05-07 at 1 16 49 PM

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is named. Start by reproducing the external $ref case in Swagger UI with the provided OpenAPI 3.0 configuration, then trace the resolver handling for API-served references; done means the remote components/parameters resolve when the operation is expanded without requiring files in the public folder.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, openapi
Domain
api, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.