swagger-angular-generator icon indicating copy to clipboard operation
swagger-angular-generator copied to clipboard

Empty enum file generated

Open wvpelt opened this issue 7 years ago • 3 comments

Having the following swagger.json:

{
  "swagger" : "2.0",
  .....
  "definitions" : {
    "MyEnum" : {
      "type" : "string",
      "enum" : [ "value1", "value2" ]
    },
    "MyDomainModel" : {
      "type" : "object",
      "properties" : {
        "enumField" : {
          "$ref" : "#/definitions/MyEnum"
        }
      },
      "example" : {
        "enumField" : "value1"
      }
    }
  }
}

A file myEnum.ts and myDomainModel.ts are both created. MyDomainModel has a field enumField with type _model.MyEnum But the MyEnum.ts is empty. How can this be resolved?

I would hope the following could be generated somehow:

export type MyEnum = 'value1' | 'value2';

export const MyEnum = {
    Value1: 'value1' as MyEnum,
    Value2: 'value2' as MyEnum
}

wvpelt avatar Nov 15 '18 09:11 wvpelt

Created pull request to add this functionality: https://github.com/jnwltr/swagger-angular-generator/pull/77

wvpelt avatar Nov 19 '18 08:11 wvpelt

Finally...

mgamsjager avatar Nov 19 '18 12:11 mgamsjager

Please have a look at the comment in the PR. We try to keep a policy that every new feature should be demonstrated in the generated files in the demo-app.

fazpu avatar Nov 29 '18 10:11 fazpu