-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
How to add a generator for a new language or framework
William Cheng edited this page Aug 11, 2018
·
2 revisions
To add an API client generator for a new language (e.g. Go), we would recommend going through the following PR as a starting point:
-
New Javascript flowtyped generator #176
Here is a summary of the changes:
- Add
modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptFlowtypedClientCodegen.java
which extendsAbstractTypeScriptClientCodegen
(other generators usually extendDefaultCodegen
). It configures the language codegen, setstemplateDir = "Javascript-Flowtyped"
which is used to locate the codegen's mustache templates, adds the template filesapi.mustache
andmodels.mustache
(see below), and adds the language CLI option. Change as necessary for your language. - Add the class to
modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig
- Add an auto-generated README file to explain how to use the auto-generated code
- Add the
modules/openapi-generator/src/main/resources/Javascript-Flowtyped/api.mustache
and model.mustache - Add samples in
samples/client/petstore/javascript-flowtyped
and.sh
and.bat
scripts to generate the samples
- Add
To add a server stub generator for a new framework (e.g. Haskell Servant), please go through the following PRs:
If you need any assistance, please open a ticket
- Tests Cases
- Shell script under
./bin/
to generate Petstore sample - Windows batch file under
.\bin\windows\
to generate Petstore sample - Unit testing for Petstore sample (e.g. unit tests for PHP Petstore SDk)
- A simple test script/app to test Petstore (e.g.
test.php
) to serve as a starting point for developers to easily play with the auto-generated SDK - Documentation
- Auto-generated
README.md
to explain the usage of the SDK - DocString for methods and models
For new generator naming, we prefer kebab-case, e.g. swift3
instead of Swift3
, erlang-server
instead of ErlangServer
.
This is not to say all the above is a must in order for the new generator to be added. If you need help implementing the above, please open a ticket and we'll help on that