Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge: develop --> main #220

Merged
merged 10 commits into from
Sep 23, 2024
Next Next commit
Implement Swagger Docs, Login UI Update (#205)
* Add basic swagger documentation (when you run, it's available at localhost:38443/cws-ui/swagger-ui/index.html)

* Adding more details to each endpoint (including tags to better sort)

* Add documentation for rest of endpoints

* Update Swagger-UI configuration to include more information about licenses, version, name, etc.

* Update documentation page to feature a link to the swagger-ui api documentation

* Update parameters

* Change method of serving documentation from auto-generated to static (but reads auto-generated info)

* Update login page to remove login box moving

* Update login page to still contain "Please log in"

* Update documentation to be CWS REST API and mention swagger

* Update login page to restore auto-color based on message passed

* Fix curl options.
wcgunter authored May 9, 2024
commit f1b3195775a1b182cb270ce28c15579b9d1509e0
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import springfox.documentation.annotations.ApiIgnore;

@Controller
@RequestMapping("/api")
@@ -27,6 +28,7 @@ public MyRestService() {
* Example POST service
*
*/
@ApiIgnore
@RequestMapping(value = "/example", method = POST)
public @ResponseBody String example(
final HttpSession session) {
11 changes: 9 additions & 2 deletions cws-service/pom.xml
Original file line number Diff line number Diff line change
@@ -29,8 +29,6 @@
<artifactId>spring-test</artifactId>
</dependency>



<!-- AWS JAVA API -->
<dependency>
<groupId>software.amazon.awssdk</groupId>
@@ -255,6 +253,15 @@
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-core</artifactId>
</dependency>

<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</dependency>
</dependencies>
</profile>
</profiles>
15 changes: 15 additions & 0 deletions cws-service/src/main/java/jpl/cws/controller/MvcCore.java
Original file line number Diff line number Diff line change
@@ -277,6 +277,21 @@ protected ModelAndView buildModelerModel(String message) {
}
return model;
}

protected ModelAndView buildApiDocsModel(String message) {
log.trace("Building apidocs's model...");
ModelAndView model = new ModelAndView("api-docs");
try {
model.addObject("base", appRoot);
model.addObject("msg", message);

log.trace("MODEL for Modeler page: "+model.getModel());
}
catch (Throwable t) {
log.error("Unexpected exception", t);
}
return model;
}

}

48 changes: 31 additions & 17 deletions cws-service/src/main/java/jpl/cws/controller/MvcService.java
Original file line number Diff line number Diff line change
@@ -31,6 +31,7 @@
import jpl.cws.process.initiation.InitiatorsService;
import jpl.cws.scheduler.Scheduler;
import jpl.cws.service.CwsConsoleService;
import springfox.documentation.annotations.ApiIgnore;

@Controller
public class MvcService extends MvcCore {
@@ -50,6 +51,7 @@ public MvcService() {}
/**
*
*/
@ApiIgnore
@RequestMapping(value = "/login", method = GET)
public ModelAndView login(final HttpSession session) {
return buildModel("login", "Please log in");
@@ -59,6 +61,7 @@ public ModelAndView login(final HttpSession session) {
/**
*
*/
@ApiIgnore
@RequestMapping(value = "/not_authorized", method = GET)
public ModelAndView notAuthorized(final HttpSession session) {
return buildModel("not_authorized", "Not authorized. Please navigate elsewhere");
@@ -68,6 +71,7 @@ public ModelAndView notAuthorized(final HttpSession session) {
/**
*
*/
@ApiIgnore
@RequestMapping(value = "/home", method = GET)
public ModelAndView index(final HttpSession session) {
return buildHomeModel("");
@@ -76,6 +80,7 @@ public ModelAndView index(final HttpSession session) {
/**
*
*/
@ApiIgnore
@RequestMapping(value = "/summary", method = GET)
public ModelAndView summary(final HttpSession session) {
return buildSummaryModel("");
@@ -87,6 +92,7 @@ public ModelAndView summary(final HttpSession session) {
* and results in displaying the home page with a welcome message
*
*/
@ApiIgnore
@RequestMapping(value = "/logintotarget", method = POST)
public ModelAndView logintotarget(
final HttpSession session,
@@ -140,26 +146,26 @@ public ModelAndView logintotarget(
return buildHomeModel("Welcome " + (user == null ? username : user.getFirstName()));
}
}


@ApiIgnore
@RequestMapping(value = "/deployments", method = GET)
public ModelAndView deployments() {
return buildDeploymentsModel("");
}


@ApiIgnore
@RequestMapping(value = "/logs", method = GET)
public ModelAndView logs() {
return buildLogsModel("");
}


@ApiIgnore
@RequestMapping(value = "/history", method = GET)
public ModelAndView history() {
return buildHistoryModel("");
}


@ApiIgnore
@RequestMapping(value = "/workers", method = GET)
public ModelAndView workers() {
return buildWorkersModel();
@@ -170,6 +176,7 @@ public ModelAndView workers() {
* Returns Initiators page model and view
*
*/
@ApiIgnore
@RequestMapping(value = "/initiators", method = GET)
public ModelAndView initiators() {
ModelAndView model = new ModelAndView("initiators");
@@ -187,44 +194,51 @@ public ModelAndView initiators() {
}
return model;
}


@ApiIgnore
@RequestMapping(value = "/snippets", method = GET)
public ModelAndView snippets() {
ModelAndView model = new ModelAndView("snippets");
model.addObject("base", appRoot);
model.addObject("msg", "");
return model;
}


@ApiIgnore
@RequestMapping(value = "/processes", method = GET)
public ModelAndView processes() {
return buildProcessesModel("");
}


@ApiIgnore
@RequestMapping(value = "/configuration", method = GET)
public ModelAndView configuration() {
return buildConfigurationModel("");
}


@ApiIgnore
@RequestMapping(value = "/documentation", method = GET)
public ModelAndView documentation() {
return buildDocumentationModel("");
}


@ApiIgnore
@RequestMapping(value = "/modeler", method = GET)
public ModelAndView modeler() {
return buildModelerModel("");
}

@ApiIgnore
@RequestMapping(value = "/api-docs", method = GET)
public ModelAndView apidocs() {
return buildApiDocsModel("");
}


/**
*
*/
@ApiIgnore
@RequestMapping(value = "/logout", method = GET)
public ModelAndView logout(
final HttpSession session,
Loading