Manweill / swagger-axios-codegen

swagger client to use axios and typescript
MIT License
306 stars 83 forks source link

Unsupported type definition #3

Closed ruschka closed 5 years ago

ruschka commented 6 years ago

Hi, consider following swagger example:

{
    ...
    definitions: {
        Abc: {
            properties: {
                id: {
                type: "string"
            }
        },
        ArrayOfAbc: {
            type: "array",
            items: {
                $ref: "#/definitions/Abc"
            }
        }
    },
    ...
}

Method createDefinitionClass in definitionCodegen.ts expects all types have property properties, but array doesn't. Generation with such swagger file fails with error:

(node:16624) UnhandledPromiseRejectionWarning: TypeError: Cannot convert undefined or null to object
    at Function.entries (<anonymous>)
    at createDefinitionClass (C:\Data\node\logio-promo-pricing\node_modules\swagger-axios-codegen\dist\definitionCodegen.js:65:39)
    at Object.definitionsCodeGen (C:\Data\node\logio-promo-pricing\node_modules\swagger-axios-codegen\dist\definitionCodegen.js:101:34)
    at codegen (C:\Data\node\logio-promo-pricing\node_modules\swagger-axios-codegen\dist\index.js:56:38)
    at Object.<anonymous> (C:\Data\node\logio-promo-pricing\packages\data-pump\src\swagger\codegen.js:3:1)
    at Module._compile (module.js:649:14)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
Manweill commented 6 years ago

It is usually not like this, you can see example. But, I will fix this issue in next version

Manweill commented 5 years ago

fix in 0.3