Cannot read property '1' of undefined (Swagger Hub)
See original GitHub issueQ&A (please complete the following information)
- OS: Windows 10
- Browser: chrome
- Version: Swagger Hub
- Method of installation: Swagger Hub
- Swagger-UI version: Swagger Hub
- Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration
I am encountering an error in swagger hub that is particularly annoying and seems to occur haphazardly. This issue seemed to be resolved in the past however it is appearing for me in SwaggerHub. The error Cannot Read Property ‘1’ of undefined explodes and makes swagger hub unusable until refreshed.
Example Swagger/OpenAPI definition:
openapi: 3.0.0
components:
schemas:
QuestionBase:
type: object
properties:
question:
type: string
type:
type: string
options:
type: object
QuestionInputBase:
allOf:
- $ref: '#/components/schemas/QuestionBase'
- type: object
required:
- type
QuestionInputById:
allOf:
- $ref: '#/components/schemas/QuestionInputBase'
- type: object
required:
- id
properties:
id:
type: integer
QuestionInputWithOrder:
allOf:
- $ref: '#/components/schemas/QuestionInputBase'
- type: object
required:
- order
- type
properties:
order:
type: integer
minimum: 1
QuestionInputWithOrderById:
allOf:
- $ref: '#/components/schemas/QuestionInputWithOrder'
- type: object
required:
- id
properties:
id:
type: integer
minimum: 1
QuestionInputWithNested:
allOf:
- $ref: '#/components/schemas/QuestionInputBase'
- type: object
required:
- type
properties:
type:
type: string
example: "ranking"
subQuestions:
type: array
items:
oneOf:
- $ref: '#/components/schemas/QuestionInputById'
- $ref: '#/components/schemas/QuestionInputWithOrder'
- $ref: '#/components/schemas/QuestionInputWithOrderById'
Describe the bug you’re encountering
Cannot read property ‘1’ of undefined occurring whenever QuestionInputWithNested is expanded in the UI.
To reproduce…
Steps to reproduce the behavior:
- Go to Swagger Editor
- Copy and paste the YAML
- Scroll down to QuestionInputWithNested in the UI.
- Expand
- Watch the explosion of Cannot read property 1 of undefined errors
Screenshots
Additional context or thoughts
These seems to happen because QuestionInputWithOrderById is referencing QuestionInputById as part of an allOf. When QuestionInputWithOrderById is removed from the oneOf list of the subQuestions property on the QuestionInputWithNested the issue seems to be fixed. This is strange to me because I am using the same pattern elsewhere and it doesn’t cause the same error. I will get around this for now by removing the inheritance which for some reason or another is causing these circular import errors 😦
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:18 (4 by maintainers)
Top GitHub Comments
Hi,
is there any update on this issue? I have an API definition in openapi v3 and face the same issue. I checked with the example from @Moro-Code above and I get the same error with the react component.
Hmmmm, yeah I see this too.
Good timing @Moro-Code, I’m looking at a similar internal report today, might be related.