You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by vo...@apache.org on 2020/08/01 13:08:19 UTC

[fineract] branch develop updated: FINERACT-838 Added Swagger Codegen Support (#1206)

This is an automated email from the ASF dual-hosted git repository.

vorburger pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git


The following commit(s) were added to refs/heads/develop by this push:
     new 1f46261  FINERACT-838 Added Swagger Codegen Support (#1206)
1f46261 is described below

commit 1f462613fbb8832602365bf21de26f88ade5f930
Author: Chinmay Kulkarni <30...@users.noreply.github.com>
AuthorDate: Sat Aug 1 18:38:10 2020 +0530

    FINERACT-838 Added Swagger Codegen Support (#1206)
    
    incl. doc in README and new docs/developers/swagger/client.md
---
 README.md                                    |  8 ++++++++
 docs/developers/swagger/client.md            | 26 ++++++++++++++++++++++++++
 fineract-provider/build.gradle               | 17 +++++++++++++++++
 fineract-provider/config/swagger/config.json | 11 +++++++++++
 4 files changed, 62 insertions(+)

diff --git a/README.md b/README.md
index 4c93bd0..4ed3398 100644
--- a/README.md
+++ b/README.md
@@ -263,6 +263,14 @@ API clients (Web UIs, Mobile, etc.)
 * https://github.com/openMF has more related proejcts
 
 
+Generate Apache Fineract API Client
+============
+
+Apache Fineract supports client code generation using [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) based on the [OpenAPI Specification Version 3.0.3](https://swagger.io/specification/).
+
+For more instructions on how to generate the client code, check `docs/developers/swagger/client.md`
+
+
 Online Demos
 ============
 
diff --git a/docs/developers/swagger/client.md b/docs/developers/swagger/client.md
new file mode 100644
index 0000000..c854340
--- /dev/null
+++ b/docs/developers/swagger/client.md
@@ -0,0 +1,26 @@
+Generate Apache Fineract API Client
+============
+
+Apache Fineract supports client code generation using [Swagger Codegen](https://github.com/swagger-api/swagger-codegen). Project supports [all clients](https://github.com/swagger-api/swagger-codegen#overview) supported by Swagger Codegen. It uses [OpenAPI Specification Version 3.0.3](https://swagger.io/specification/).
+
+## Generate API Client
+
+In root directory of the project:
+
+- Run `./gradlew build`
+- Run `./gradlew generateSwaggerCode`
+
+The client code will be generated under `build/swagger-code-fineract`
+
+## Build API Client:
+
+- Run `cd build/swagger-code-fineract`
+- Run `./gradlew build`
+
+## Customize Code Generator:
+
+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`
+- Customize options
+- Build the project again as mentioned in **Generate API Client Code** section
\ No newline at end of file
diff --git a/fineract-provider/build.gradle b/fineract-provider/build.gradle
index ca2c290..dc85adc 100644
--- a/fineract-provider/build.gradle
+++ b/fineract-provider/build.gradle
@@ -56,6 +56,7 @@ buildscript {
         classpath "net.ltgt.gradle:gradle-errorprone-plugin:1.2.1"
         classpath "com.diffplug.spotless:spotless-plugin-gradle:5.1.0"
         classpath "io.swagger.core.v3:swagger-gradle-plugin:2.1.4"
+        classpath "gradle.plugin.org.hidetake:gradle-swagger-generator-plugin:2.18.1"
     }
 }
 
@@ -79,6 +80,7 @@ apply plugin: "com.gorylenko.gradle-git-properties"
 apply plugin: "net.ltgt.errorprone"
 apply plugin: "com.diffplug.spotless"
 apply plugin: "io.swagger.core.v3.swagger-gradle-plugin"
+apply plugin: "org.hidetake.swagger.generator"
 
 dependencyManagement {
     imports {
@@ -848,3 +850,18 @@ gitProperties {
 
 // make sure the generateGitProperties task always executes (even when git.properties is not changed)
 generateGitProperties.outputs.upToDateWhen { false }
+
+//This is for swagger code generation
+dependencies {
+    swaggerCodegen 'io.swagger.codegen.v3:swagger-codegen-cli:3.0.20'
+}
+
+swaggerSources {
+    fineract {
+        inputFile = file('../build/classes/java/main/static/swagger-ui/fineract.yaml')
+        code {
+            language = 'java'
+            configFile = file('config/swagger/config.json')
+        }
+    }
+}
diff --git a/fineract-provider/config/swagger/config.json b/fineract-provider/config/swagger/config.json
new file mode 100644
index 0000000..2a15328
--- /dev/null
+++ b/fineract-provider/config/swagger/config.json
@@ -0,0 +1,11 @@
+{
+   "groupId": "org.apache.fineract",
+   "artifactId": "client",
+   "artifactVersion": "1.4.0",
+   "invokerPackage": "org.apache.fineract.client",
+   "modelPackage": "org.apache.fineract.client.models",
+   "apiPackage": "org.apache.fineract.client.services",
+   "dateLibrary": "joda",
+   "hideGenerationTimestamp": "true",
+   "library": "retrofit2"
+}