FINERACT-1101 Swagger Codegen build using Gradle
This commit is contained in:
committed by
Michael Vorburger ⛑️
parent
e0f81f00fe
commit
a86c5cfde1
@@ -7,20 +7,40 @@ Apache Fineract supports client code generation using [Swagger Codegen](https://
|
||||
|
||||
In root directory of the project:
|
||||
|
||||
- Run `./gradlew build`
|
||||
- Run `./gradlew resolve`
|
||||
- Run `./gradlew generateSwaggerCode`
|
||||
|
||||
The client code will be generated under `build/swagger-code-fineract`
|
||||
|
||||
## Build API Client:
|
||||
## Build API Client
|
||||
|
||||
- Run `cd build/swagger-code-fineract`
|
||||
- Run `./gradlew build`
|
||||
|
||||
## Customize Code Generator:
|
||||
Alternatively, if you have Maven installed on your system, you can also do:
|
||||
|
||||
- Run `cd build/swagger-code-fineract`
|
||||
- Run `mvn clean package`
|
||||
|
||||
## Customize Generated Code
|
||||
|
||||
Swagger Codegen provides several options to customize the generated code. [Here](https://openapi-generator.tech/docs/generators/java/) are the options available for customization.
|
||||
|
||||
- Open `fineract-provider/config/swagger/config.json`
|
||||
- Open the [config.json.template](https://github.com/apache/fineract/blob/develop/fineract-provider/config/swagger/config.json.template) file
|
||||
- Customize options
|
||||
- Build the project again as mentioned in **Generate API Client Code** section
|
||||
- Build the project again as mentioned in **Generate API Client Code** section
|
||||
|
||||
## Customize using Mustache Templates
|
||||
|
||||
Swagger Codegen uses Mustache Templates for generating the client library. For additional customizations you can add/edit custom templates inside the `fineract-provider/config/swagger/templates` folder.
|
||||
|
||||
Make sure you are following the supported templates. Otherwise, the generated code will not build correctly.
|
||||
|
||||
- [Java Mustache Templates](https://github.com/swagger-api/swagger-codegen/tree/master/modules/swagger-codegen/src/main/resources/Java)
|
||||
- [Retrofit2 Mustache Templates](https://github.com/swagger-api/swagger-codegen/tree/master/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2)
|
||||
|
||||
If you need to add templates for a specific library, you need to follow the same directory structure as present in the links above.
|
||||
|
||||
## Validate OpenAPI Spec File
|
||||
|
||||
The `resolve` task in [build.gradle](https://github.com/apache/fineract/blob/217e34ba9e4cf04ad7b82fc3a0f8f8e5f8de8042/fineract-provider/build.gradle#L212) file will generate the OpenAPI Spec File for the project. To make sure Swagger Codegen generates a correct library, it is important for the OpenAPI Spec file to be valid. Use [Swagger OpenAPI Validator](https://validator.swagger.io/) to validate the spec file.
|
||||
Reference in New Issue
Block a user