swagger-api / swagger-ui

Swagger UI is a collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.
https://swagger.io
Apache License 2.0
26.48k stars 8.96k forks source link

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

Open avrahamGross opened 5 months ago

avrahamGross commented 5 months ago

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

ritikmodi commented 1 month ago

Hey @avrahamGross, were you able to solve the issue? I am also facing the same issue. Could you please help me with the solution. Thanks.

avrahamGross commented 1 month ago

@ritikmodi I can't say I solved it but I did bypass it. I wrapped the updateJsonSpec action with a custom resolver function and passed that resolved object to the swagger ui component. Hope this helps!