Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[javascript client] constructFromObject calls undefined function constructFromObject on enums #3639

Closed
rgarcia opened this issue Aug 24, 2016 · 0 comments

Comments

@rgarcia
Copy link

rgarcia commented Aug 24, 2016

Description

When constructing an object, the generated javascript client recursively calls constructFromObject on enum types. This method is not defined on enum types.

Swagger-codegen version

Latest master (8c2267c)

Swagger declaration file content or url
swagger: '2.0'
info:
  title: test title
  description: test description
  version: 0.1.0
schemes:
  - http
produces:
  - application/json
consumes:
  - application/json
paths:
  /foos:
    post:
      operationId: createFoo
      description: Create a new Foo
      tags:
        - Foos
      parameters:
        - name: CreateFooRequest
          in: body
          schema:
            $ref: '#/definitions/CreateFooRequest'
          required: true
      responses:
        200:
          description: OK response

definitions:
  CreateFooRequest:
    type: object
    properties:
      bar:
        $ref: '#/definitions/Bar'
  Bar:
    type: string
    enum:
      - baz1
      - baz2
      - baz3
Command line used for generation

java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i swagger.yml -l javascript -o gen-js

Steps to reproduce
  1. Run codegen against the above config.
  2. Open src/model/CreateFooRequest.js and notice this logic for constructing the enum:
      if (data.hasOwnProperty('bar')) {
        obj['bar'] = Bar.constructFromObject(data['bar']);
      }

If you open src/model/Bar.js, there is no constructFromObject method on that type.

Related issues

Didn't find any.

Suggest a Fix

Still digging...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant