Swagger-Codegen: How do I consolidate all files into one file for Client-Code-Generation Swagger-Codegen: How do I consolidate all files into one file for Client-Code-Generation express express

Swagger-Codegen: How do I consolidate all files into one file for Client-Code-Generation


TL; DR

You may compile all files into a single *.ts file as shown at this post.

Continuous Integration Approach

Swagger code generator simplifies maintenance because it allows you to think in terms of continuous integrations.

You should not be worried about code review or aesthetics (because it is a machine generated code), but about:

  • API versioning
  • Functions, methods and classes signatures
  • Documentation

If you are working with a CI system such as Jenkins or Ansible, you could automatically deploy the library to a private NPM account (for JS and TS) or Maven server (for Java and Kotlin).

Private Maven

Keeping the package version number consistently updated will allow the IDE to correctly prompt the user about updates on the API.

enter image description here


Swagger uses Mustache templates for generating the code. For making simplerchanges you can simple create a copy of one of the built-in templates andmodify that.

Then you can use your modified template like this:

swagger-codegen-cli generate -t path/to/template/dir/ -i spec.json

The output directory structure, however, cannot be changed using templatesalone. For that you'd need a custom codegen module. You can either create yourown or modify one of the built-in ones.