Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$ref resolution may fail. #10232

Open
hogegex opened this issue Dec 3, 2024 · 0 comments
Open

$ref resolution may fail. #10232

hogegex opened this issue Dec 3, 2024 · 0 comments

Comments

@hogegex
Copy link

hogegex commented Dec 3, 2024

Q&A (please complete the following information)

  • OS: Windows 10 22H2
  • Browser: Chrome
  • Version: 131.0.6778.86
  • Method of installation: Docker Image (swaggerapi/swagger-ui:v5.18.2)
  • Swagger-UI version: v5.18.2
  • Swagger/OpenAPI version: OpenAPI 3.0.3

Content & configuration

Example Swagger/OpenAPI definition:

openapi: 3.0.3
info:
  title: SomeWebAPI
  version: 1.0.0
servers:
  - url: "https://example.com/v1"
paths:
  /endpoint:
    get:
      description: Description
      responses:
        "422":
          description: Error
          content:
            application/json:
              schema:
                $ref: "#/components/responses/SomeResponse/content/application~1json/schema/allOf/0"
    post:
      description: Description
      requestBody:
        description: Description
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SomeRequest"
      responses:
        "404":
          $ref: "#/components/responses/SomeResponse"
components:
  schemas:
    SomeRequest:
      type: object
  responses:
    SomeResponse:
      description: Description
      content:
        application/json:
          schema:
            allOf:
              - type: object
              - type: object

Swagger-UI configuration options: Docker image default

Describe the bug you're encountering

The following error appears at the top of the Swagger UI page:

Errors
 
Resolver error at paths./endpoint.get.responses.422.content.application/json.schema.$ref
Could not resolve reference: Could not resolve pointer: /components/responses/SomeResponse/content/application~1json/schema/allOf/0 does not exist in document

Also, the schema is not loaded and the path of the reference is displayed instead.

To reproduce...

Steps to reproduce the behavior:

  1. Save the above OpenAPI yaml as openapi.yaml.

  2. Start Swagger UI with the following command:

    docker run -v <PATH_TO_LOCAL_OPENAPI_YAML>:/openapi.yaml -e SWAGGER_JSON=/openapi.yaml -p 8002:8080 --rm swaggerapi/swagger-ui:v5.18.2

  3. Access http://localhost:8002 in your browser.

  4. Open the endpoint definitions POST /endpoint -> GET /endpoint.

  5. See error

Expected behavior

No errors occur and the schema loads.

Screenshots

N/A

Additional context or thoughts

  • If I change the order of opening the endpoint definitions to GET /endpoint -> POST /endpoint, the error does not occur.

    This issue seems to depend on the order of operations in the UI.

  • This issue also occurred on https://editor.swagger.io/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant