Manweill / swagger-axios-codegen

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

Include extra types which are not included when services are filtered #117

Closed fairking closed 3 years ago

fairking commented 4 years ago

If we use include filter sometimes I need some extra schemes (types) to add into the output file.

I have added an additional option includeTypes which is an array of type names to achieve the requirement.

Eg. I have some extra enumerators which are not referenced in any of my service methods. Without using filters they all are rendered. But with filters they are not.

Eg.

codegen_module1.js:

codegen({
        outputDir: "./src/services",
    fileName: 'module1.ts',
    include: ["MyAppModule1*"],
    includeTypes: ["Module1PermissionsEnum"],

codegen_module2.js:

codegen({
        outputDir: "./src/services",
    fileName: 'module2.ts',
    include: ["MyAppModule2*"],
    includeTypes: ["Module2PermissionsEnum"],

package.json:

"scripts": {
    "codegen_module1": "rimraf ./src/services/module1.ts && node ./codegen/module1.js",
    "codegen_module2": "rimraf ./src/services/module2.ts && node ./codegen/module2.js",
fairking commented 3 years ago

PR is merged down, so closing the request. Tested, everything is working fine.