Swagger Codegen Generators
If the default generator configuration does not meet your needs, you have various options to modify or create new modules or templates.
Modifying the client library format
Don’t like the default swagger client syntax? Want a different language supported? No problem!
Swagger Codegen processes handlebar templates with the Handlebars.java engine. You can modify our templates or make your own.
Take a look at swagger-codegen-generators for examples. To make your own templates, create your own files and use the -t
flag to specify your template folder. It actually is that easy!
Making your own codegen modules
If you’re starting a project with a new language and don’t see what you need, Swagger Codegen can help you create a project to generate your own libraries:
This will write, in the folder output/myLibrary
, all the files you need to get started, including a README.md
. Once modified and compiled, you can load your library with the codegen and generate clients with your own, custom-rolled logic.
You would then compile your library in the output/myLibrary
folder with mvn package
and execute the codegen like such:
For Windows users, you will need to use ;
instead of :
in the classpath, e.g.:
Note the myClientCodegen
is an option now, and you can use the usual arguments for generating your library:
See also standalone generator development.
Generating a client from local files
If you don’t want to call your server, you can save the OpenAPI Description files into a directory and pass an argument to the code generator like this:
Great for creating libraries on your CI server, from the Swagger Editor … or while coding on an airplane ✈️.