FINERACT-1528: Replace copy and pasted Swagger UI with Springdoc

This commit is contained in:
Aleksandar Vidakovic
2022-05-02 14:30:49 +02:00
committed by Arnold Gálovics
parent 3bc160c33c
commit 4bef3ba6b8
24 changed files with 91 additions and 203 deletions
+4 -25
View File
@@ -68,10 +68,10 @@ rat.dependsOn prepareInputYaml
resolve {
logging.captureStandardOutput LogLevel.INFO
outputFileName = 'fineract'
outputFormat = 'YAML'
outputFormat = 'JSONANDYAML'
prettyPrint = true
classpath = sourceSets.main.runtimeClasspath
outputDir = file("${buildDir}/generated/swagger-ui")
outputDir = file("${buildDir}/classes/java/main/static")
openApiFile = file("config/swagger/fineract-input.yaml")
sortOutput = true
}
@@ -215,34 +215,22 @@ bootRun {
implementation 'org.mariadb.jdbc:mariadb-java-client:2.7.5'
implementation 'org.postgresql:postgresql:42.3.4'
}
classpath += files("build/generated/swagger-ui")
}
springBoot {
mainClass = 'org.apache.fineract.ServerApplication'
buildInfo()
}
bootJar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
manifest {
attributes 'Main-Class': 'org.springframework.boot.loader.PropertiesLauncher', 'Implementation-Title': 'Apache Fineract', 'Implementation-Version': archiveVersion
attributes('Main-Class': 'org.springframework.boot.loader.PropertiesLauncher', 'Implementation-Title': 'Apache Fineract', 'Implementation-Version': archiveVersion)
}
dependsOn resolve
classifier = ''
from('build/generated/swagger-ui') {
into 'BOOT-INF/classes/static/swagger-ui'
}
}
jar {
from('build/generated/swagger-ui') {
include '*'
}
}
jar.dependsOn resolve
jar.dependsOn bootJar
jib {
@@ -296,15 +284,6 @@ jib {
implementation 'org.postgresql:postgresql:42.3.4'
}
extraDirectories {
paths {
path {
from = file('build/generated/swagger-ui')
into = "/app/classes"
}
}
}
pluginExtensions {
pluginExtension {
implementation = 'com.google.cloud.tools.jib.gradle.extension.layerfilter.JibLayerFilterExtension'
@@ -3,19 +3,11 @@ info:
version: @VERSION@
title: Apache Fineract
description: |-
Apache Fineract is a secure, multi-tenanted microfinance platform
The goal of the Apache Fineract API is to empower developers to build apps on top of the Apache Fineract Platform<br>The [reference app](https://cui.fineract.dev) (username: mifos, password: password) works on the same demo tenant as the interactive links in this documentation
- The API is organized around [REST](https://en.wikipedia.org/wiki/Representational_state_transfer)
- Find out more about Apache Fineract [here](/fineract-provider/api-docs/apiLive.htm#top)
- You can [Try The API From Your Browser](/fineract-provider/api-docs/apiLive.htm#interact)
- The Generic Options are available [here](/fineract-provider/api-docs/apiLive.htm#genopts)
- Find out more about [Updating Dates and Numbers](/fineract-provider/api-docs/apiLive.htm#dates_and_numbers)
- For the Authentication and the Basic of HTTP and HTTPS refer [here](/fineract-provider/api-docs/apiLive.htm#authentication_overview)
- Check about ERROR codes [here](/fineract-provider/api-docs/apiLive.htm#errors)
Please refer to the [old documentation](/fineract-provider/api-docs/apiLive.htm) for any documentation queries
Apache Fineract is a secure, multi-tenanted microfinance platform.
The goal of the Apache Fineract API is to empower developers to build apps on top of the Apache Fineract Platform.
The <a href="https://cui.fineract.dev" target="_blank">reference app</a> (username: mifos, password: password) works on the same demo tenant as the interactive links in this documentation.
Until we complete the new REST API documentation you still have the legacy documentation available <a href="../legacy-docs/apiLive.htm" target="_blank">here</a>.
Please check <a href="https://fineract.apache.org/docs/current" target="_blank">the Fineract documentation</a> for more information.
contact:
email: dev@fineract.apache.org
license:
+15 -5
View File
@@ -63,13 +63,22 @@ dependencies {
'com.github.spotbugs:spotbugs-annotations',
'io.swagger.core.v3:swagger-annotations',
'org.webjars:webjars-locator-core',
'com.google.cloud.sql:mysql-socket-factory-connector-j-8:1.5.0',
'com.squareup.retrofit2:converter-gson',
'org.apache.commons:commons-email'
'com.sun.activation:jakarta.activation',
'com.sun.mail:jakarta.mail',
'org.springdoc:springdoc-openapi-ui',
'org.springdoc:springdoc-openapi-common',
'org.springdoc:springdoc-openapi-security',
)
implementation ('org.apache.commons:commons-email:1.5') {
exclude group: 'com.sun.mail', module: 'javax.mail'
exclude group: 'javax.activation', module: 'activation'
}
implementation('org.springframework.boot:spring-boot-starter-jersey') {
exclude group: 'org.glassfish.hk2.external', module: 'aopalliance-repackaged'
exclude group: 'org.glassfish.hk2', module: 'hk2-runlevel'
@@ -84,11 +93,12 @@ dependencies {
}
implementation ('org.apache.activemq:activemq-broker') {
exclude group: 'org.apache.geronimo.specs'
exclude group: 'javax.annotation', module: 'javax.annotation-api'
}
implementation ('org.springframework.boot:spring-boot-starter-data-jpa') {
exclude group: 'org.hibernate'
}
implementation('org.eclipse.persistence:org.eclipse.persistence.jpa:2.7.10') {
implementation('org.eclipse.persistence:org.eclipse.persistence.jpa') {
exclude group: 'org.eclipse.persistence', module: 'jakarta.persistence'
}
implementation ('org.quartz-scheduler:quartz') {
@@ -100,13 +110,14 @@ dependencies {
implementation ('org.mnode.ical4j:ical4j') {
exclude group: 'commons-logging'
exclude group: 'javax.activation'
exclude group: 'com.sun.mail', module: 'javax.mail'
}
implementation ('org.ehcache:ehcache') {
exclude group: 'com.sun.activation'
}
implementation('org.owasp.esapi:esapi:2.3.0.0') {
implementation('org.owasp.esapi:esapi') {
exclude group: 'org.slf4j'
exclude group: 'log4j'
exclude group: 'commons-logging'
@@ -125,7 +136,6 @@ dependencies {
runtimeOnly(
'org.apache.bval:org.apache.bval.bundle',
'org.springframework.boot:spring-boot-starter-actuator',
'org.webjars.npm:swagger-ui-dist',
// Although fineract (at the time of writing) doesn't have any compile time dep. on httpclient,
// it's useful to have this for the Spring Boot TestRestTemplate http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot-features-rest-templates-test-utility
@@ -1,60 +0,0 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.infrastructure.core.config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.webjars.WebJarAssetLocator;
@EnableWebMvc
@Configuration
public class WebFrontEndConfiguration implements WebMvcConfigurer {
private static final Logger LOG = LoggerFactory.getLogger(WebFrontEndConfiguration.class);
private static final String[] CLASSPATH_RESOURCE_LOCATIONS = { "classpath:/static/", "classpath:/public/" };
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
if (!registry.hasMappingForPattern("/**")) {
registry.addResourceHandler("/**").addResourceLocations(CLASSPATH_RESOURCE_LOCATIONS);
}
WebJarAssetLocator locator = new WebJarAssetLocator();
String fullPathToSwaggerUiJs = locator.getFullPath("swagger-ui.js");
LOG.info("Found Swagger UI at {}", fullPathToSwaggerUiJs);
String fullPathToSwaggerUi = fullPathToSwaggerUiJs.substring(0, fullPathToSwaggerUiJs.lastIndexOf("/") + 1);
final String[] swaggerResourceLocations = { "classpath:/static/swagger-ui/", "classpath:fineract.yaml",
"classpath:" + fullPathToSwaggerUi };
registry.addResourceHandler("/swagger-ui/**").addResourceLocations(swaggerResourceLocations);
}
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addRedirectViewController("/swagger-ui", "/swagger-ui/index.html");
registry.addRedirectViewController("/swagger-ui/", "/swagger-ui/index.html");
}
}
@@ -120,7 +120,7 @@ public class SurveyApiResource {
@Produces({ MediaType.APPLICATION_JSON })
@Operation(summary = "Create an entry in the survey table", description = "Insert and entry in a survey table (full fill the survey)."
+ "\n" + "\n"
+ "Refer Link for sample Body: [ https://demo.fineract.dev/fineract-provider/api-docs/apiLive.htm#survey_create ] ")
+ "Refer Link for sample Body: [ https://demo.fineract.dev/fineract-provider/legacy-docs/apiLive.htm#survey_create ] ")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = SurveyApiResourceSwagger.PostSurveySurveyNameApptableIdRequest.class)))
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = SurveyApiResourceSwagger.PostSurveySurveyNameApptableIdResponse.class))) })
@@ -200,7 +200,7 @@ public class AccountsApiResource {
+ "requestedDate is requsted date of shares redeem\n" + "\n" + "requestedShares is number of shares to be redeemed\n\n"
+ "Mandatory Fields: dateFormat,locale,requestedDate,requestedShares\n\n"
+ "Showing request/response for 'Reject additional shares request on a share account'\n\n"
+ "For more info visit this link - https://demo.fineract.dev/fineract-provider/api-docs/apiLive.htm#shareaccounts")
+ "For more info visit this link - https://demo.fineract.dev/fineract-provider/legacy-docs/apiLive.htm#shareaccounts")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = AccountsApiResourceSwagger.PostAccountsTypeAccountIdRequest.class)))
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = AccountsApiResourceSwagger.PostAccountsTypeAccountIdResponse.class))) })
@@ -53,7 +53,7 @@ public class SelfAuthenticationApiResource {
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
@Operation(summary = "Verify authentication", description = "Authenticates the credentials provided and returns the set roles and permissions allowed.\n\n"
+ "Please visit this link for more info - https://demo.fineract.dev/fineract-provider/api-docs/apiLive.htm#selfbasicauth")
+ "Please visit this link for more info - https://demo.fineract.dev/fineract-provider/legacy-docs/apiLive.htm#selfbasicauth")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = SelfAuthenticationApiResourceSwagger.PostSelfAuthenticationResponse.class))) })
public String authenticate(final String apiRequestBodyAsJson) {
@@ -52,7 +52,7 @@ public class SelfUserDetailsApiResource {
@GET
@Produces({ MediaType.APPLICATION_JSON })
@Operation(summary = "Fetch authenticated user details", description = "Checks the Authentication and returns the set roles and permissions allowed\n\n"
+ "For more info visit this link - https://demo.fineract.dev/fineract-provider/api-docs/apiLive.htm#selfoauth")
+ "For more info visit this link - https://demo.fineract.dev/fineract-provider/legacy-docs/apiLive.htm#selfoauth")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = SelfUserDetailsApiResourceSwagger.GetSelfUserDetailsResponse.class))) })
public String fetchAuthenticatedUserData() {
@@ -17,6 +17,8 @@
# under the License.
#
application.title=Apache Fineract
fineract.node-id=${FINERACT_NODE_ID:1}
fineract.security.basicauth.enabled=${FINERACT_SECURITY_BASICAUTH_ENABLED:true}
@@ -111,3 +113,15 @@ spring.liquibase.parameters.fineract.tenant.port=${fineract.tenant.port}
spring.liquibase.parameters.fineract.tenant.username=${fineract.tenant.username}
spring.liquibase.parameters.fineract.tenant.password=${fineract.tenant.password}
spring.liquibase.parameters.fineract.tenant.parameters=${fineract.tenant.parameters}
springdoc.api-docs.path=${SPRINGDOC_API_DOCS_PATH:/api-docs}
springdoc.api-docs.enabled=${SPRINGDOC_API_DOCS_ENABLED:true}
springdoc.swagger-ui.enabled=${SPRINGDOC_SWAGGER_UI_ENABLED:true}
springdoc.swagger-ui.display-query-params=true
springdoc.swagger-ui.url=/fineract.json
springdoc.packagesToScan=org.apache.fineract
springdoc.pathsToMatch=/api/**
springdoc.use-management-port=${SPRINGDOC_USE_MANAGEMENT_PORT:false}
springdoc.show-actuator=${SPRINGDOC_SHOW_ACTUATOR:false}
spring.web.resources.static-locations=classpath:/static/
@@ -6,7 +6,7 @@
/_/ \_\ .__/ \__,_|\___|_| |_|\___| |_| |_|_| |_|\___|_| \__,_|\___|\__|
|_|
${AnsiStyle.FAINT}${AnsiColor.WHITE}version ${application.version}${AnsiColor.BLACK}
${AnsiStyle.FAINT}${AnsiColor.WHITE}(c) 2015-2022 ${application.title} (https://fineract.apache.org)${AnsiColor.BLACK}
${AnsiStyle.FAINT}${AnsiColor.WHITE}Powered by Spring Boot ${spring-boot.version}${AnsiColor.BLACK}
@@ -1,65 +0,0 @@
<!-- HTML for static distribution bundle build -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Swagger UI</title>
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" >
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
<style>
html
{
box-sizing: border-box;
overflow: -moz-scrollbars-vertical;
overflow-y: scroll;
}
*,
*:before,
*:after
{
box-sizing: inherit;
}
body
{
margin:0;
background: #fafafa;
}
</style>
</head>
<body>
<div id="swagger-ui"></div>
<script src="./swagger-ui-bundle.js"> </script>
<script src="./swagger-ui-standalone-preset.js"> </script>
<script>
window.onload = function() {
// Begin Swagger UI call region
const ui = SwaggerUIBundle({
url: "fineract.yaml",
dom_id: '#swagger-ui',
deepLinking: true,
filter: '',
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "BaseLayout",
onComplete: function() {
ui.preauthorizeBasic("basicAuth", "mifos", "password");
ui.preauthorizeApiKey("tenantid", "default");
}
})
// End Swagger UI call region
window.ui = ui
}
</script>
</body>
</html>