Skip to content

0.10.2: ReferenceError: name is not defined #1485

Closed

Description

@mmattb

ReferenceError: name is not defined
at /ifs/home/mbryan/.npm/_npx/3518/lib/node_modules/redoc-cli/node_modules/redoc/bundles/redoc.lib.js:9404:124
at mapValues (/ifs/home/mbryan/.npm/_npx/3518/lib/node_modules/redoc-cli/node_modules/redoc/bundles/redoc.lib.js:7269:24)
at new FieldModel (/ifs/home/mbryan/.npm/_npx/3518/lib/node_modules/redoc-cli/node_modules/redoc/bundles/redoc.lib.js:9404:29)
at /ifs/home/mbryan/.npm/_npx/3518/lib/node_modules/redoc-cli/node_modules/redoc/bundles/redoc.lib.js:9741:50
at Array.map ()
at OperationModel.get (/ifs/home/mbryan/.npm/_npx/3518/lib/node_modules/redoc-cli/node_modules/redoc/bundles/redoc.lib.js:9741:15)
at OperationModel.get (/ifs/home/mbryan/.npm/_npx/3518/lib/node_modules/redoc-cli/node_modules/redoc/bundles/redoc.lib.js:8600:42)
at Object.children (/ifs/home/mbryan/.npm/_npx/3518/lib/node_modules/redoc-cli/node_modules/redoc/bundles/redoc.lib.js:14129:97)
at ReactDOMServerRenderer.render (/ifs/home/mbryan/.npm/_npx/3518/lib/node_modules/redoc-cli/node_modules/react-dom/cjs/react-dom-server.node.development.js:3635:55)
at ReactDOMServerRenderer.read (/ifs/home/mbryan/.npm/_npx/3518/lib/node_modules/redoc-cli/node_modules/react-dom/cjs/react-dom-server.node.development.js:3373:29)

It appears this happens on 0.10.2 and not 0.10.1. It happens with some YAML files and not others, and presumably that is why I'm the first to report it. Probably I have a weird edge-case of a YAML file, though: the repro below is pretty minimal.

I've made a semi-minimalist version of the file that reproduces the issue. The 'examples' clause seems to be a crucial part of it.

---
openapi: "3.0.3"
info:
  description: "Hello"
  version: "2.0"
  title: "Hello"
  contact:
    email: "hello@dell.com"
servers:
  - url: http://hello.com/2/query
paths:
  /query:
    get:
      summary: "Hello"
      description: "Hello"
      parameters:
        - in: query
          name: sumfing
          schema:
            type: string
          examples:
            some_example:
              value: something

Activity

  1. StephaneLambert commented on Dec 18, 2020

    @StephaneLambert

    Same trouble for me with NodeJS 12.19 et redoc-cli 0.10.2, not with 0.10.1.
    Clarification: redoc-cli serve is OK while redoc-cli bundle is NOT.

    My YAML sample :

    openapi: 3.0.2
    info:
      title: Test Redoc Bundle
      version: 1.0.0
      description: Redoc Bundle fail if headers are used ?
    paths:
      /entities:
        summary: '...'
        description: '...'
        get:
          parameters:
            - examples:
                all:
                  value: 0-5/6
                page2:
                  value: 20-39/258
              name: Content-Range
              description: |-
                Content-Range: `offset`–`limit`/`count`
                  * offset : ...
                  * limit : ...
                  * count : ...
              schema:
                type: string
              in: header
          responses:
            '200':
              content:
                application/json:
                  schema:
                    type: array
                    items:
                      $ref: '#/components/schemas/entities'
              description: Successful response - returns an array of `entities` entities.
          operationId: getentities
          summary: List All entities
          description: Gets a list of all `entities` entities.
    components:
      schemas:
        entities:
          description: ''
          type: object
          properties:
            property1:
              description: property1 description
              type: string
            property2:
              description: property2 description
              type: integer
    
  2. dowy commented on Mar 7, 2021

    @dowy

    That line:
    .../node_modules/redoc-cli/node_modules/redoc/bundles/redoc.lib.js:9404:124
    points to the variable "name" but there is no such variable.
    It should refer to the "this.name" assigned on line 9391.

    My javascript isn't strong enough to figure out how "name" on line 9404 can refer to "this.name" on line 9391 so I added a local variable:

    --- redoc.lib.js        2021-03-08 10:04:59.848676574 +1300
    +++ redoc.lib.js.patched        2021-03-08 10:05:46.578731187 +1300
    @@ -9383,12 +9383,12 @@
      */
     var Field_FieldModel = /** @class */ (function () {
         function FieldModel(parser, infoOrRef, pointer, options) {
    -        var _a, _b, _c, _d;
    +        var _a, _b, _c, _d, name;
             this.expanded = false;
             Object(external_mobx_["makeObservable"])(this);
             var info = parser.deref(infoOrRef);
             this.kind = infoOrRef.kind || 'field';
    -        this.name = infoOrRef.name || info.name;
    +        name = this.name = infoOrRef.name || info.name;
             this.in = info.in;
             this.required = !!info.required;
             var fieldSchema = info.schema;

    I leave it to someone who knows what they're doing to raise a patch for this.

  3. EvanCarroll commented on Mar 26, 2021

    @EvanCarroll

    @RomanHotsiy why was this issue closed?

  4. EvanCarroll commented on Mar 26, 2021

    @EvanCarroll

    @dowy I'm confused how this isn't broken for everyone.

  5. RomanHotsiy commented on Mar 26, 2021

    @RomanHotsiy
    Member

    @EvanCarroll because It was fixed.

    Could you specify more details? Which version of openapi-cli do you use? What node version?

  6. RomanHotsiy commented on Mar 26, 2021

    @RomanHotsiy
    Member

    @EvanCarroll I just tested it again and it works for me on the latest redoc-cli@0.10.4 version.

  7. added a commit that references this issue on Dec 5, 2021
    63ead20
  8. added a commit that references this issue on Oct 6, 2025
    0dce880
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions