fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vorbur...@apache.org
Subject [fineract] branch develop updated: FINERACT-910: Serving apiDocs as part of the fineract-provider
Date Mon, 11 May 2020 17:59:26 GMT
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 b58404b  FINERACT-910: Serving apiDocs as part of the fineract-provider
b58404b is described below

commit b58404be410db74e5891030a12c5d2ccb191f5ae
Author: Petri Tuomola <petri@tuomola.org>
AuthorDate: Sun May 3 13:42:14 2020 +0300

    FINERACT-910: Serving apiDocs as part of the fineract-provider
---
 .github/PULL_REQUEST_TEMPLATE.MD                   |  2 +-
 fineract-provider/build.gradle                     |  1 +
 .../fineract/integrationtests/ApiDocsTest.java     | 47 ++++++++++++++++++++++
 .../core/boot/WebFrontEndConfiguration.java        | 16 +++++---
 .../main/resources/static/api-docs}/apiLive.htm    |  0
 .../main/resources/static/api-docs}/apidocs.css    |  0
 .../resources/static/api-docs}/jquery-1.7.min.js   |  0
 7 files changed, 59 insertions(+), 7 deletions(-)

diff --git a/.github/PULL_REQUEST_TEMPLATE.MD b/.github/PULL_REQUEST_TEMPLATE.MD
index 7ba444e..39568c5 100644
--- a/.github/PULL_REQUEST_TEMPLATE.MD
+++ b/.github/PULL_REQUEST_TEMPLATE.MD
@@ -8,7 +8,7 @@ Please make sure these boxes are checked before submitting your pull request
- t
 
 - [ ] Coding conventions at https://cwiki.apache.org/confluence/display/FINERACT/Coding+Conventions
have been followed.
 
-- [ ] API documentation at https://github.com/apache/fineract/blob/develop/api-docs/apiLive.htm
has been updated with details of any API changes.
+- [ ] API documentation at fineract-provider/src/main/resources/static/api-docs/apiLive.htm
has been updated with details of any API changes.
 
 - [ ] Integration tests have been created/updated for verifying the changes made.
 
diff --git a/fineract-provider/build.gradle b/fineract-provider/build.gradle
index fec5e5e..6d0d156 100644
--- a/fineract-provider/build.gradle
+++ b/fineract-provider/build.gradle
@@ -424,6 +424,7 @@ license {
         "**/package-info.java",
         "**/keystore.jks",
         "**/swagger-ui/**",
+        "**/api-docs/**",
     ])
     strictCheck true
 }
diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ApiDocsTest.java
b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ApiDocsTest.java
new file mode 100644
index 0000000..3faaffd
--- /dev/null
+++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ApiDocsTest.java
@@ -0,0 +1,47 @@
+/**
+ * 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.integrationtests;
+
+import io.restassured.builder.RequestSpecBuilder;
+import io.restassured.builder.ResponseSpecBuilder;
+import io.restassured.http.ContentType;
+import io.restassured.specification.RequestSpecification;
+import io.restassured.specification.ResponseSpecification;
+import org.apache.fineract.integrationtests.common.Utils;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ApiDocsTest {
+
+    private ResponseSpecification responseSpec;
+    private RequestSpecification requestSpec;
+
+    @Before
+    public void setup() {
+        Utils.initializeRESTAssured();
+        this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
+        this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
+    }
+
+    @Test
+    public void testApiDocsAccess() {
+        Utils.performServerGet(requestSpec, responseSpec, "/fineract-provider/api-docs/apiLive.htm",
null);
+    }
+
+}
diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/boot/WebFrontEndConfiguration.java
b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/boot/WebFrontEndConfiguration.java
index 3566323..06c6b97 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/boot/WebFrontEndConfiguration.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/boot/WebFrontEndConfiguration.java
@@ -27,11 +27,15 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 @Configuration
 public class WebFrontEndConfiguration implements WebMvcConfigurer {
 
-    @Override
-    public void addResourceHandlers(ResourceHandlerRegistry registry) {
-        registry.addResourceHandler("/apps/**").addResourceLocations("file:" +
-                System.getProperty("user.dir") + System.getProperty("file.separator") +
-                "apps" + System.getProperty("file.separator"));
-    }
+  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);
+    }
+  }
 }
diff --git a/api-docs/apiLive.htm b/fineract-provider/src/main/resources/static/api-docs/apiLive.htm
similarity index 100%
rename from api-docs/apiLive.htm
rename to fineract-provider/src/main/resources/static/api-docs/apiLive.htm
diff --git a/api-docs/apidocs.css b/fineract-provider/src/main/resources/static/api-docs/apidocs.css
similarity index 100%
rename from api-docs/apidocs.css
rename to fineract-provider/src/main/resources/static/api-docs/apidocs.css
diff --git a/api-docs/jquery-1.7.min.js b/fineract-provider/src/main/resources/static/api-docs/jquery-1.7.min.js
similarity index 100%
rename from api-docs/jquery-1.7.min.js
rename to fineract-provider/src/main/resources/static/api-docs/jquery-1.7.min.js


Mime
View raw message