Skip to content

Commit

Permalink
Implement Swagger Docs, Login UI Update (#205)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
wcgunter authored May 9, 2024
1 parent 0cbda38 commit f1b3195
Show file tree
Hide file tree
Showing 14 changed files with 492 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -27,6 +28,7 @@ public MyRestService() {
* Example POST service
*
*/
@ApiIgnore
@RequestMapping(value = "/example", method = POST)
public @ResponseBody String example(
final HttpSession session) {
Expand Down
11 changes: 9 additions & 2 deletions cws-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
<artifactId>spring-test</artifactId>
</dependency>



<!-- AWS JAVA API -->
<dependency>
<groupId>software.amazon.awssdk</groupId>
Expand Down Expand Up @@ -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>
Expand Down
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
Expand Up @@ -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
Expand Up @@ -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 {
Expand All @@ -50,6 +51,7 @@ public MvcService() {}
/**
*
*/
@ApiIgnore
@RequestMapping(value = "/login", method = GET)
public ModelAndView login(final HttpSession session) {
return buildModel("login", "Please log in");
Expand All @@ -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");
Expand All @@ -68,6 +71,7 @@ public ModelAndView notAuthorized(final HttpSession session) {
/**
*
*/
@ApiIgnore
@RequestMapping(value = "/home", method = GET)
public ModelAndView index(final HttpSession session) {
return buildHomeModel("");
Expand All @@ -76,6 +80,7 @@ public ModelAndView index(final HttpSession session) {
/**
*
*/
@ApiIgnore
@RequestMapping(value = "/summary", method = GET)
public ModelAndView summary(final HttpSession session) {
return buildSummaryModel("");
Expand All @@ -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,
Expand Down Expand Up @@ -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();
Expand All @@ -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");
Expand All @@ -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,
Expand Down
Loading

0 comments on commit f1b3195

Please sign in to comment.