verizonconnect / ngx-form-generator

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

Crash when schema object type is array #90

Open av314 opened 1 year ago

av314 commented 1 year ago

According to the OpenAPI spec: "The Schema Object allows the definition of input and output data types. These types can be objects, but also primitives and arrays."

However, ngx-form-generator crashes when the schema is of type array.

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
...

A schema Object example from the OpenAPI spec with an array:

animals:
  type: array
  items:
    type: string
{
    "animals": {
        "type": "array",
        "items": {
            "type": "string"
        }
    }
}

Or:

    Cdns:
      type: array
      items:
        type: string
        $ref: "#/components/schemas/Cdn"

Thanks,

Arjen

av314 commented 1 year ago

ngx-form-generator also crashes when the schema has an element of type 'string'. It seems only 'object' is accepted in the schema section.