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.

Cannot read property '1' of undefined (Swagger Hub)

See original GitHub issue

Q&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:

  1. Go to Swagger Editor
  2. Copy and paste the YAML
  3. Scroll down to QuestionInputWithNested in the UI.
  4. Expand
  5. 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:open
  • Created 4 years ago
  • Reactions:4
  • Comments:18 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
alexaandcommented, Dec 9, 2019

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.

3reactions
shockeycommented, Jul 1, 2019

Hmmmm, yeah I see this too.

Good timing @Moro-Code, I’m looking at a similar internal report today, might be related.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Swagger - Cannot read property 'get' of undefined
I try create a documentation about existing API using swagger, but when i use openapi, this error: Cannot read property 'get' of undefined...
Read more >
Solved: Editor full of resolver errors - SmartBear Community
Cannot read property 'properties' of undefined. I have stripped down the API to just what is necessary to reproduce the issue.
Read more >
Solved: Error when integrating Custom API: Cannot read pro...
when Integrating the following custom API i get the Error: Cannot read property 'parameters' of undefined. Same happens when I use the default.json...
Read more >
OpenAPI Specification - Version 2.0 - Swagger
Version 2.0 specification defines a set of files required to describe an API. ... This property does not define global parameters for all...
Read more >
Uncaught TypeError: Cannot read property 'definitions' of null
You received this message because you are subscribed to a topic in the Google Groups "Swagger" group. To unsubscribe from this topic, visit...
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