Openapi-generator: [REQ] [Typescript] Only generate types with no services calls

Created on 17 Jul 2019  路  5Comments  路  Source: OpenAPITools/openapi-generator

Is your feature request related to a problem? Please describe.

We have a requirement to add cancel tokens to our Axios service calls and have already written this layer. I want to be able to only generate Typescript typings without the axios/fetch service calls (since I would have to write a generator to get cancel token sent to Axios).

Describe the solution you'd like

Option to generate Typescript types only (does this require a new generator type [typescript]?)

Describe alternatives you've considered

I've considered using the following: https://github.com/horiuchi/dtsgenerator, but would rather use OpenApi Generator because of the huge following/support.

Additional context

Feature

All 5 comments

Option to generate Typescript types only (does this require a new generator type [typescript]?)

If you want to generate certain files only, you may consider using .openapi-generator-ignore (readme => customization has more info on that)

If you want to customize the templates, please use the -t option (of the latest stable version)

@swillis12 you could also add a postprocessor that generates typings from the generated services and deletes the generated services

Thanks @macjohnny, that was a great idea. I was able to script this and it is working well for me. I will leave this open since this would still be an intuitive feature for other people that are in the same boat as me (written a service layer already and just need generated types).

I will continue using only the generated models until I get the time to write a template that supports adding an Axios cancel token or if https://github.com/OpenAPITools/openapi-generator/issues/3383 gets fixed.

@wing328 Is there a good example of using the -t option to customize or extend an existing template? Does this require making a copy of the axios-typescript template as a whole and then doing modifications thereafter?

There is the option -D models you could pass to the generate command when typescript-angular generator is used, but I'm not sure if this also works when using typescript-axios.

Was this page helpful?
0 / 5 - 0 ratings