Error resolving $ref pointer, Redocly Standalone
See original GitHub issueHi,
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:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
We may support it in one of the upcoming versions after we finish migrating to openapi-core: https://github.com/Redocly/redoc/pull/1500
@nitram509 fixed: #1500