question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error resolving $ref pointer, Redocly Standalone

See original GitHub issue

Hi,

I’m Using Redocly v2.0.0-rc.48 standalone in a custom portal, which in general works like a charm, BUT some of my API specs are not rendered 😕

I understand, that in the spec the reference is missing, but in my ideal world, redocly is robust and renders what’s possible. Just for reference, I did try editor.swagger.io and it still renders something.

Observed error

Error resolving $ref pointer "http://localhost:9090/doc.json#/definitions/string". Token "string" does not exist.
Stack trace
SyntaxError: Error resolving $ref pointer "http://localhost:9090/doc.json#/definitions/string". 
Token "string" does not exist.
    at Pointer.resolve (webpack:///./node_modules/json-schema-ref-parser/lib/pointer.js?:87:17)
    at $Ref.resolve (webpack:///./node_modules/json-schema-ref-parser/lib/ref.js?:83:18)
    at $Refs._resolve (webpack:///./node_modules/json-schema-ref-parser/lib/refs.js?:155:15)
    at inventory$Ref (webpack:///./node_modules/json-schema-ref-parser/lib/bundle.js?:98:23)
    at eval (webpack:///./node_modules/json-schema-ref-parser/lib/bundle.js?:73:11)
    at Array.forEach (<anonymous>)
    at crawl (webpack:///./node_modules/json-schema-ref-parser/lib/bundle.js?:67:12)
    at eval (webpack:///./node_modules/json-schema-ref-parser/lib/bundle.js?:76:11)
    at Array.forEach (<anonymous>)

Expected behavior

Redocly should be robust enough to skip missing references, print a warning, and renders what possible. Alternatively, I might also find an optional error handler useful, which I could configure when I instantiate the standalone object. With this approach, I would be able to choose to fail fast and deny rendering or try the best approach to render it (robustness).

Problematic file

{
    "schemes": [],
    "swagger": "2.0",
    "info": {
        "description": "pdfgen service",
        "title": "PDFGen service",
        "version": "1.0"
    },
    "host": "www.example.com",
    "basePath": "/pdfgen/v1",
    "paths": {
        "/pdfgen/v1/templates/{template-name}": {
            "get": {
                "description": "The template version is taken from the parameter store.",
                "produces": [
                    "text/plain"
                ],
                "tags": [
                    "pdfgen"
                ],
                "summary": "Retrieve a template",
                "operationId": "get-template",
                "parameters": [
                    {
                        "type": "string",
                        "description": "name of the template to render with",
                        "name": "templateName",
                        "in": "query",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "zip file containing specified template",
                        "schema": {
                            "$ref": "#/definitions/string"
                        }
                    }
                }
            }
        }
    },
    "definitions": {
        "pkg.templateArray": {
            "type": "array",
            "items": {
                "type": "string"
            }
        }
    },
    "securityDefinitions": {
        "BasicAuth": {
            "type": "basic"
        }
    }
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
RomanHotsiycommented, Jan 28, 2021

We may support it in one of the upcoming versions after we finish migrating to openapi-core: https://github.com/Redocly/redoc/pull/1500

0reactions
andriylcommented, Apr 9, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

Redocly CLI changelog
Resolved an issue with transitive $ref resolution in the JSON schema validator. If the JSON schema validator crashes, OpenAPI CLI will now ...
Read more >
Reference docs changelog - Redocly
Resolved an issue with switching languages in code samples not working correctly with duplicated language and different labels.
Read more >
Workflows changelog - Redocly
Resolved an issue where Reference and Portal builds dependent on API definitions were not triggered if any of the build jobs in the...
Read more >
Use the Redoc HTML element
How to use the Redoc HTML element · Step 1 - Install Redoc · Step 2 - Reference the Redoc script · Step...
Read more >
Open-source software used in the Redocly developer portal
@babel/standalone@7.9.6, MIT ... @pieh/friendly-errors-webpack-plugin@1.7.0-chalk-2, MIT ... character-reference-invalid@1.1.4, MIT.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found