... | ... | @@ -4,13 +4,13 @@ First off, the codegen project has transforming logic as well as templates for e |
|
|
|
|
|
https://github.com/openapitools/openapi-generator/tree/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages
|
|
|
|
|
|
Each template does a few things, namely generate a data structure from the swagger specification (note: the codegen project will transform previous versions of the swagger spec into a 2.0 specification before performing the transformation. See the [Swagger-Parser](https://github.com/swagger-api/swagger-parser) project for details). While you do not necessarily need to perform transformations, it's likely necessary, or every programming language would have roughly the same syntax.
|
|
|
Each template does a few things, namely generate a data structure from the OpenAPI specification (note: the codegen project will transform previous versions of the OpenAPI spec into a 2.0 specification before performing the transformation. See the [Swagger-Parser](https://github.com/swagger-api/swagger-parser) project for details). While you do not necessarily need to perform transformations, it's likely necessary, or every programming language would have roughly the same syntax.
|
|
|
|
|
|
The transform logic needs to implement [CodegenConfig.java](https://github.com/openapitools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConfig.java) and is most easily done by extending [DefaultCodegen.java](https://github.com/openapitools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java). Take a look at the various implementations as a guideline while the instructions get more complete.
|
|
|
|
|
|
Aside from transforming, the implementing class gets to decide "what to do" with the data structure. Namely, which data structures to apply to which template files. You have the following at your disposal:
|
|
|
|
|
|
1) Operations. There is a data structure which represents all the operations that are defined in the swagger specification. A single file is created for each `OperationGroup`, which is essentially a grouping of different operations. See the `addOperationToGroup` in `DefaultCodegen.java` for details on this operation.
|
|
|
1) Operations. There is a data structure which represents all the operations that are defined in the OpenAPI specification. A single file is created for each `OperationGroup`, which is essentially a grouping of different operations. See the `addOperationToGroup` in `DefaultCodegen.java` for details on this operation.
|
|
|
|
|
|
You can have many files created for each `OperationGroup` by processing multiple templates and assigning a different file naming pattern to them. So for a single file per operation:
|
|
|
|
... | ... | |