verizonconnect / ngx-form-generator

Generate Angular ReactiveForms from OpenAPI documents
MIT License
44 stars 12 forks source link

Handle OpenAPI Enums #51

Open fabianmue opened 2 years ago

fabianmue commented 2 years ago

The OpenAPI 3.0 spec allows to define enums: https://swagger.io/docs/specification/data-models/enums/

An example of such an enum in .json format looks like this:

"Propertyname": { "enum": [ "A", "B" ], "type": "string" },

Currently, if the input swagger.json contains such enums, the generation fails:

...\node_modules\@verizonconnect\ngx-form-generator\dist\generator-lib.js:52
    const fields = Object.keys(definition.properties);
                          ^

TypeError: Cannot convert undefined or null to object

It would be nice if the generator could handle .json files with such inputs (for example skip over them).

If you agree, I can maybe submit a PR.

martinmcwhorter commented 1 year ago

Yes, please submit a PR for this.