swagger-api / swagger-api/swagger-ui

Resolver error: f is undefined

Open
#5,820 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cat: $ref resolution
Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

Q&A
  • OS: Windows 10
  • Browser: does not matter (chrome, ff)
  • Version: does not matter
  • Swagger-UI version: http://editor.swagger.io/
  • Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration

Example Swagger/OpenAPI definition:

openapi: 3.0.1
info:
  title: DbSync API
  version: v1
paths:
  '/api/v{version}/db-sync/generate-script':
    post:
      tags:
        - DbSyncV1
      parameters:
        - name: version
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GenerateScriptRequest'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GenerateScriptResponse'
components:
  schemas:
    EntityRelatedType:
      enum:
        - None
        - Direct
        - Update
        - LazyDirect
        - Inverse
        - Connected
      type: string
    EntityRelation:
      type: object
      properties:
        sourceAttribute:
          type: string
          nullable: true
        targetAttribute:
          type: string
          nullable: true
        relatedType:
          allOf:
            - $ref: '#/components/schemas/EntityRelatedType'
        filter:
          type: string
          nullable: true
      additionalProperties: false
    EntityMetadata:
      type: object
      properties:
        name:
          type: string
          nullable: true
        keys:
          type: array
          items:
            type: string
          nullable: true
        relation:
          allOf:
            - $ref: '#/components/schemas/EntityRelation'
          nullable: true
        relatedEntities:
          type: array
          items:
            $ref: '#/components/schemas/EntityMetadata'
          nullable: true
      additionalProperties: false
    SourceEnvironment:
      enum:
        - Source1
        - Source2
      type: string
    GenerateScriptRequest:
      type: object
      properties:
        aggregateMetadata:
          allOf:
            - $ref: '#/components/schemas/EntityMetadata'
          nullable: true
        rootId:
          type: integer
          format: int32
        source:
          allOf:
            - $ref: '#/components/schemas/SourceEnvironment'
      additionalProperties: false
    GenerateScriptResponse:
      type: object
      properties:
        sqlScript:
          type: string
          nullable: true
      additionalProperties: false
Describe the bug you're encountering

editor.swagger.io reports errors, when trying to expand schema description.

To reproduce...

Steps to reproduce the behavior:

  1. Go to editor.swagger.io
  2. Enter the YAML above
  3. Expand GenerateScriptRequest
  4. Scroll top and you'll see several errors: Resolver error - f is undefined
Additional context or thoughts
  1. Also there is no array element type displayed when I expand array relatedEntities in EntityMetadata
  2. Error is gone if I change the type of relatedType field in EntityRelation to string (just for example)
  3. There is an array in EntityMetadata that contains EntityMetadatas (is it considered as cycle?)
  4. The error happens when the object contains enum EntityRelatedType as descendant (if i replace it with SourceEnvironment error remains)
  5. The error happens only when expanding GenerateScriptRequest but not EntityMetadata or EntityRelation

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue in editor.swagger.io with the supplied OpenAPI 3.0 YAML, then start at the schema expansion path for GenerateScriptRequest and the reported resolver error. Done means expanding the request no longer reports “f is undefined” and the relatedEntities array displays its EntityMetadata element type.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.