swagger-js: Resolver error - Cannot read property '0' of undefined (it's is back)
From @ofavre on August 3, 2018 11:54
Q&A (please complete the following information)
- OS: Linux
- Browser: Chrome
- Version: 67.0.3396.99
- Method of installation: https://editor.swagger.io
- Swagger-UI version: Probably the latest, 3.17.6 as of this writing
- Swagger/OpenAPI version: Swagger 2.0
Content & configuration
Example Swagger/OpenAPI definition:
swagger: '2.0'
info:
title: Test
version: '1.0'
basePath: /
schemes:
- https
paths:
/get:
get:
summary: Gets things
responses:
'200':
description: ''
schema:
$ref: '#/definitions/A'
definitions:
D:
type: object
properties:
z:
type: string
description: Some Z string
C:
type: object
properties:
d:
title: D
allOf:
- description: Some D
- $ref: '#/definitions/D'
B:
type: object
properties:
c:
title: C
allOf:
- description: Some C
- $ref: '#/definitions/C'
A:
type: object
properties:
b:
title: B
allOf:
- $ref: '#/definitions/B'
- description: Some B
Swagger-UI configuration options: No idea, I’m testing on editor.swagger.io.
Describe the bug you’re encountering
In essence, #3366 is back, or had only been partially fixed.
To reproduce…
Steps to reproduce the behavior:
- Go to https://editor.swagger.io/
- Enter the Swagger above
- Expand anything you will until you reach the definition of A under the models. Check that you see no error (in your console or the top of the document.
- Now expand
Ain the models list - Scroll top and you’ll see 4 time the error:
Resolver error - Cannot read property '0' of undefined.
Expected behavior
The visual output is fine in this example, however there are javascript errors emitted (and the online editor shows them).
Screenshots

Additional context or thoughts
I found this while investigating why some other properties do not show their description, so these JavaScript errors may (or may not) be actually hurting more than it seems in this contrived example.
As suggested in #3366, if you move the A entry under definitions above B (right above or up higher) the problem disappears. If you remove one level of nesting (remove A and make the end-point reference B directly), you get no issue. However putting the definitions above the paths changes nothing.
Copied from original issue: swagger-api/swagger-ui#4787
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 8
- Comments: 17 (7 by maintainers)
Commits related to this issue
- fix(resolver): bail out from all-off plugin prematurely This bugfix solves nostalgic problem with reference resolution manifesting as error: Cannot read property '0' of undefined. There was an attem... — committed to swagger-api/swagger-js by char0n 4 years ago
- fix(resolver): bail out from all-off plugin prematurely This bugfix solves nostalgic problem with reference resolution manifesting as error: Cannot read property '0' of undefined. There was an attem... — committed to swagger-api/swagger-js by char0n 4 years ago
- fix(resolver): bail out from all-off plugin prematurely (#1783) This bugfix solves nostalgic problem with reference resolution manifesting as error: Cannot read property '0' of undefined. There w... — committed to swagger-api/swagger-js by char0n 4 years ago
@char0n thanks for the information! I will keep an eye on the releases 😃. Thanks for all the effort
@Rutix we usually release during Thursdays. It will not automatically re-buble into swagger-ui because we use exact version match for swagger-client. We’ll release swagger-ui along with swagger-client.
Fix introduced in https://github.com/swagger-api/swagger-js/pull/1783
Related issues: https://github.com/swagger-api/swagger-ui/issues/5435