cyclosproject / ng-openapi-gen

An OpenAPI 3.0 codegen for Angular
MIT License
397 stars 132 forks source link

Inline boolean enum values are converted to strings #122

Closed okirmis closed 3 years ago

okirmis commented 4 years ago

Hi everyone,

using this very helpful tool (thank you for that!) we ran into an issue (certainly an edge case) with boolean inline enum values.

While it might seem strange to use enums of type boolean, being able to define constant values is sometimes necessary (e.g. specifying that a certain property is always true or false in some case), which to our knowledge is currently only possible using enums with a single value.

Using the following OpenAPI type definition

objectPropertyName:
  enum:
   - false
  type: boolean

leads to the following interface definition being generated:

objectPropertyName: 'false'

which is not correct in my opinion and should be objectPropertyName: false (without quotes, e.g. a boolean not a string). While it might be a rare usecase, I think we should fix that. I already created a working PR (#121).