swagger-api/swagger-codegen

invalid enum generation on javascript-closure-angular-client and typescript-angular-client

Open

#2,739 建立於 2016年4月29日

在 GitHub 查看
 (3 留言) (0 反應) (0 負責人)HTML (12,701 star) (5,474 fork)batch import
Client: JavaScript/Node.jsClient: TypeScriptFeature: EnumIssue: Bughelp wanted

描述

Using swagger editor 2.9.9 when I generate a closure angular or typescript angular enums are not properly defined when spaces appear in the string. They are normalized in the javascript client.

schema:

{
  "swagger" : "2.0",
  "info" : {
    "description" : "Enum",
    "version" : "1.0.0",
    "title" : "Enum"
  },
  "host" : "localhost",
  "basePath" : "/api",
  "schemes" : [ "http" ],
  "consumes" : [ "application/json" ],
  "produces" : [ "application/json" ],
  "paths" : {
    "/example" : {
      "post" : {
        "summary" : "Example",
        "parameters" : [ {
          "in" : "body",
          "name" : "body",
          "required" : true,
          "schema" : {
            "$ref" : "#/definitions/body"
          }
        } ],
        "responses" : {
          "200" : {
            "description" : "success"
          }
        }
      }
    }
  },
  "definitions" : {
    "body" : {
      "type" : "object",
      "properties" : {
        "someProperty" : {
          "type" : "string",
          "enum" : [ "1", "Good", "With Spaces" ]
        }
      }
    }
  }
}

JAVASCRIPT CLIENT

exports.SomePropertyEnum = { 
    /**
     * value: 1
     * @const
     */
    _1: "1",

    /**
     * value: Good
     * @const
     */
    GOOD: "Good",

    /**
     * value: With Spaces
     * @const
     */
    WITH_SPACES: "With Spaces"
  };

JAVASCRIPT CLOSURE ANGULAR CLIENT

API.Client.Body.SomePropertyEnum = { 
  1: '1',
  Good: 'Good',
  With Spaces: 'With Spaces',
}

TYPESCRIPT ANGULAR CLIENT

export enum SomePropertyEnum { 
  1 = <any> '1',
  Good = <any> 'Good',
  With Spaces = <any> 'With Spaces'
}

貢獻者指南

invalid enum generation on javascript-closure-angular-client and typescript-angular-client · swagger-api/swagger-codegen#2739 | Good First Issue