|
|
### Where to start?
|
|
|
|
|
|
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:
|
|
|
|
|
|
- [[Go] Add Go API client generator #1747](https://github.com/swagger-api/swagger-codegen/pull/1747).
|
|
|
|
|
|
Here is a summary of the changes:
|
|
|
- Add [`modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GoClientCodegen.java`](https://github.com/wing328/swagger-codegen/blob/20e531d6dd0a8ed71d1b8cab62ad869f56f700bc/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GoClientCodegen.java) which extends `DefaultCodegen`. It configures the language codegen, sets `templateDir = "go"` which is used to locate the codegen's mustache templates, adds the template files `api.mustache` and `models.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/io.swagger.codegen.CodegenConfig`](https://github.com/wing328/swagger-codegen/blob/20e531d6dd0a8ed71d1b8cab62ad869f56f700bc/modules/openapi-generator/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig)
|
|
|
- Add a [`modules/openapi-generator/src/main/resources/go/README.mustache`](https://github.com/wing328/swagger-codegen/blob/20e531d6dd0a8ed71d1b8cab62ad869f56f700bc/modules/openapi-generator/src/main/resources/go/README.mustache)
|
|
|
- Add the [`modules/openapi-generator/src/main/resources/go/api.mustache`](https://github.com/wing328/swagger-codegen/blob/20e531d6dd0a8ed71d1b8cab62ad869f56f700bc/modules/openapi-generator/src/main/resources/go/api.mustache) and [modules/openapi-generator/src/main/resources/go/model.mustache](https://github.com/wing328/swagger-codegen/blob/20e531d6dd0a8ed71d1b8cab62ad869f56f700bc/modules/openapi-generator/src/main/resources/go/model.mustache)
|
|
|
- Add samples in `samples/client/petstore/go` and `.sh` and `.bat` scripts to generate the samples
|
|
|
|
|
|
To add a server stub generator for a new framework (e.g. Haskell Servant), please go through the following PRs:
|
|
|
|
|
|
- [Code generator for haskell-servant framework #2009](https://github.com/swagger-api/swagger-codegen/pull/2009)
|
|
|
- [[aspnet] Initial implementation of ASP.NET 5 server #2024](https://github.com/swagger-api/swagger-codegen/pull/2024)
|
|
|
|
|
|
If you need any assistance, please open a [ticket](https://github.com/openapitools/openapi-generator/issues)
|
|
|
|
|
|
### Checklist (a list of items we look for in the new generator):
|
|
|
* 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](https://github.com/openapitools/openapi-generator/tree/master/samples/client/petstore/php/OpenAPIToolsClient-php/tests))
|
|
|
* [ ] 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](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles), 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](https://github.com/openapitools/openapi-generator/issues) and we'll help on that** |
|
|
\ No newline at end of file |