redoc: Incorrectly parsed reference fails to resolve

I’m using the latest stable CDN-hosted ReDoc version on the Swagger 2.0 and JSON Schema documents at the end of this post. When loading this in ReDoc, it fails with the following error: ERROR Error: Uncaught (in promise): SyntaxError: Error resolving $ref pointer "http://127.0.0.1:5000/about/json/schema#/definitions/schema". Token "schema" does not exist.. As you can see in the documents below, this subschema does indeed not exist, but I don’t know why ReDoc tries to load it. I’m hoping someone here might. The same JSON schema is also parsed and resolved by a Python library, which works well, so at this point like the error is caused by something on ReDoc’s side.

Please let me know if I can provide more information. Once https://github.com/Rebilly/ReDoc/issues/388 has been addressed, I can hopefully help debug this error myself locally 😃

Swagger spec:

{
   "swagger":"2.0",
   "info":{
      "title":"Alfred",
      "version":"0.0.0",
      "description":"This document describes Alfred's HTTP API in the [OpenApi 2.0](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md) format."
   },
   "definitions":{

   },
   "parameters":{

   },
   "paths":{
      "/about/json/schema":{
         "get":{
            "operationId":"schema",
            "consumes":[

            ],
            "produces":[
               "application/schema+json"
            ],
            "responses":{
               "200":{
                  "description":"A successful response.",
                  "schema":{
                     "$ref":"http://127.0.0.1:5000/about/json/schema#/definitions/response/schema"
                  }
               },
               "406":{
                  "$ref":"#/responses/406"
               },
               "415":{
                  "$ref":"#/responses/415"
               }
            }
         }
      },
      "/about/json/external-schema/{id}":{
         "get":{
            "operationId":"external-schema",
            "consumes":[

            ],
            "produces":[
               "application/schema+json"
            ],
            "responses":{
               "200":{
                  "description":"A successful response.",
                  "schema":{
                     "$ref":"http://127.0.0.1:5000/about/json/schema#/definitions/response/schema"
                  }
               },
               "406":{
                  "$ref":"#/responses/406"
               },
               "415":{
                  "$ref":"#/responses/415"
               }
            }
         }
      },
      "/about/openapi":{
         "get":{
            "operationId":"openapi",
            "consumes":[

            ],
            "produces":[
               "application/json",
               "text/html"
            ],
            "responses":{
               "200":{
                  "description":"A successful response.",
                  "schema":{
                     "$ref":"http://127.0.0.1:5000/about/json/schema#/definitions/response/openapi"
                  }
               },
               "406":{
                  "$ref":"#/responses/406"
               },
               "415":{
                  "$ref":"#/responses/415"
               }
            }
         }
      }
   },
   "tags":[

   ],
   "responses":{
      "406":{
         "description":"Returned if the request `Accept` header does not contain any content type produced by this endpoint."
      },
      "415":{
         "description":"Returned if the request `Content-Type` header does not contain any content type consumed by this endpoint."
      }
   },
   "host":"127.0.0.1:5000",
   "schemes":[
      "http"
   ]
}

JSON Schema:

{
   "id":"http://127.0.0.1:5000/about/json/schema",
   "$schema":"http://json-schema.org/draft-04/schema#",
   "enum":[
      null
   ],
   "definitions":{
      "request":{

      },
      "response":{
         "schema":{
            "anyOf":[
               {
                  "$ref":"http://127.0.0.1:5000/about/json/schema#/definitions/response/error"
               },
               {
                  "$ref":"http://127.0.0.1:5000/about/json/external-schema/aHR0cDovL2pzb24tc2NoZW1hLm9yZy9kcmFmdC0wNC9zY2hlbWE%3D",
                  "description":"A JSON Schema."
               }
            ]
         },
         "openapi":{
            "$ref":"http://127.0.0.1:5000/about/json/external-schema/aHR0cDovL3N3YWdnZXIuaW8vdjIvc2NoZW1hLmpzb24%3D",
            "description":"An OpenAPI/Swagger 2.0 schema."
         },
         "error":{
            "title":"Error response",
            "type":"object",
            "properties":{
               "errors":{
                  "type":"array",
                  "items":{
                     "$ref":"http://127.0.0.1:5000/about/json/schema#/definitions/data/error"
                  }
               }
            },
            "required":[
               "errors"
            ]
         }
      },
      "data":{
         "error":{
            "title":"An API error",
            "type":"object",
            "properties":{
               "code":{
                  "title":"The machine-readable error code.",
                  "type":"string"
               },
               "title":{
                  "title":"The human-readable error title.",
                  "type":"string"
               }
            },
            "required":[
               "code",
               "title"
            ]
         }
      }
   }
}

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15 (5 by maintainers)

Commits related to this issue

Most upvoted comments

Awesome, it works like a charm now. Thank you very much!