Integrated SwaggerUI for docuementing RESTful API into Maven site
Former-commit-id: 477201b7e0
restapi
parent
5d891c2c6d
commit
f7721dd41b
|
|
@ -316,6 +316,10 @@
|
||||||
<trimStackTrace>false</trimStackTrace>
|
<trimStackTrace>false</trimStackTrace>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-site-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
<!--<plugin>
|
<!--<plugin>
|
||||||
<groupId>org.jacoco</groupId>
|
<groupId>org.jacoco</groupId>
|
||||||
<artifactId>jacoco-maven-plugin</artifactId>
|
<artifactId>jacoco-maven-plugin</artifactId>
|
||||||
|
|
@ -370,6 +374,32 @@
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>io.openapitools.swagger</groupId>
|
||||||
|
<artifactId>swagger-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<resourcePackages>
|
||||||
|
<resourcePackage>org.libreccm.api</resourcePackage>
|
||||||
|
<resourcePackage>org.libreccm.api.admin</resourcePackage>
|
||||||
|
<resourcePackage>org.libreccm.api.admin.categorization</resourcePackage>
|
||||||
|
<resourcePackage>org.libreccm.api.admin.categorization.dto</resourcePackage>
|
||||||
|
<resourcePackage>org.libreccm.api.admin.configuration</resourcePackage>
|
||||||
|
<resourcePackage>org.libreccm.api.admin.security</resourcePackage>
|
||||||
|
<resourcePackage>org.libreccm.api.admin.security.dto</resourcePackage>
|
||||||
|
</resourcePackages>
|
||||||
|
<outputDirectory>${project.basedir}/src/site/resources</outputDirectory>
|
||||||
|
<outputFilename>ccm-core-api</outputFilename>
|
||||||
|
<outputFormats>JSON</outputFormats>
|
||||||
|
<prettyPrint>true</prettyPrint>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>generate</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|
@ -575,6 +605,7 @@
|
||||||
</reportSet>
|
</reportSet>
|
||||||
</reportSets>
|
</reportSets>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</reporting>
|
</reporting>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>LibreCCM Core RESTful API</title>
|
||||||
|
<script src="./swagger-ui-dist/swagger-ui-bundle.js"></script>
|
||||||
|
<script src="./swagger-ui-standalone-preset.js"></script>
|
||||||
|
<script>
|
||||||
|
document.addEventListener("DOMContentLoaded", function (event) {
|
||||||
|
const ui = SwaggerUIBundle({
|
||||||
|
dom_id: "#ccm-core-api",
|
||||||
|
url: "./ccm-core-api.json"
|
||||||
|
});
|
||||||
|
window.ui = ui;
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>LibreCCM Core RESTful API</h1>
|
||||||
|
<div id="ccm-core-api"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"openapi" : "3.0.1"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"openapi" : "3.0.1"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
# Swagger UI Dist
|
||||||
|
[](http://badge.fury.io/js/swagger-ui-dist)
|
||||||
|
|
||||||
|
# API
|
||||||
|
|
||||||
|
This module, `swagger-ui-dist`, exposes Swagger-UI's entire dist folder as a dependency-free npm module.
|
||||||
|
Use `swagger-ui` instead, if you'd like to have npm install dependencies for you.
|
||||||
|
|
||||||
|
`SwaggerUIBundle` and `SwaggerUIStandalonePreset` can be imported:
|
||||||
|
```javascript
|
||||||
|
import { SwaggerUIBundle, SwaggerUIStandalonePreset } from "swagger-ui-dist"
|
||||||
|
```
|
||||||
|
|
||||||
|
To get an absolute path to this directory for static file serving, use the exported `getAbsoluteFSPath` method:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
const swaggerUiAssetPath = require("swagger-ui-dist").getAbsoluteFSPath()
|
||||||
|
|
||||||
|
// then instantiate server that serves files from the swaggerUiAssetPath
|
||||||
|
```
|
||||||
|
|
||||||
|
For anything else, check the [Swagger-UI](https://github.com/swagger-api/swagger-ui) repository.
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
/*
|
||||||
|
* getAbsoluteFSPath
|
||||||
|
* @return {string} When run in NodeJS env, returns the absolute path to the current directory
|
||||||
|
* When run outside of NodeJS, will return an error message
|
||||||
|
*/
|
||||||
|
const getAbsoluteFSPath = function () {
|
||||||
|
// detect whether we are running in a browser or nodejs
|
||||||
|
if (typeof module !== "undefined" && module.exports) {
|
||||||
|
return require("path").resolve(__dirname)
|
||||||
|
}
|
||||||
|
throw new Error('getAbsoluteFSPath can only be called within a Nodejs environment');
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = getAbsoluteFSPath
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 665 B |
Binary file not shown.
|
After Width: | Height: | Size: 628 B |
|
|
@ -0,0 +1,60 @@
|
||||||
|
<!-- 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: "https://petstore.swagger.io/v2/swagger.json",
|
||||||
|
dom_id: '#swagger-ui',
|
||||||
|
deepLinking: true,
|
||||||
|
presets: [
|
||||||
|
SwaggerUIBundle.presets.apis,
|
||||||
|
SwaggerUIStandalonePreset
|
||||||
|
],
|
||||||
|
plugins: [
|
||||||
|
SwaggerUIBundle.plugins.DownloadUrl
|
||||||
|
],
|
||||||
|
layout: "StandaloneLayout"
|
||||||
|
})
|
||||||
|
// End Swagger UI call region
|
||||||
|
|
||||||
|
window.ui = ui
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
try {
|
||||||
|
module.exports.SwaggerUIBundle = require("./swagger-ui-bundle.js")
|
||||||
|
module.exports.SwaggerUIStandalonePreset = require("./swagger-ui-standalone-preset.js")
|
||||||
|
} catch(e) {
|
||||||
|
// swallow the error if there's a problem loading the assets.
|
||||||
|
// allows this module to support providing the assets for browserish contexts,
|
||||||
|
// without exploding in a Node context.
|
||||||
|
//
|
||||||
|
// see https://github.com/swagger-api/swagger-ui/issues/3291#issuecomment-311195388
|
||||||
|
// for more information.
|
||||||
|
}
|
||||||
|
|
||||||
|
// `absolutePath` and `getAbsoluteFSPath` are both here because at one point,
|
||||||
|
// we documented having one and actually implemented the other.
|
||||||
|
// They were both retained so we don't break anyone's code.
|
||||||
|
module.exports.absolutePath = require("./absolute-path.js")
|
||||||
|
module.exports.getAbsoluteFSPath = require("./absolute-path.js")
|
||||||
|
|
@ -0,0 +1,68 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en-US">
|
||||||
|
<title>Swagger UI: OAuth2 Redirect</title>
|
||||||
|
<body onload="run()">
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
<script>
|
||||||
|
'use strict';
|
||||||
|
function run () {
|
||||||
|
var oauth2 = window.opener.swaggerUIRedirectOauth2;
|
||||||
|
var sentState = oauth2.state;
|
||||||
|
var redirectUrl = oauth2.redirectUrl;
|
||||||
|
var isValid, qp, arr;
|
||||||
|
|
||||||
|
if (/code|token|error/.test(window.location.hash)) {
|
||||||
|
qp = window.location.hash.substring(1);
|
||||||
|
} else {
|
||||||
|
qp = location.search.substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
arr = qp.split("&")
|
||||||
|
arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';})
|
||||||
|
qp = qp ? JSON.parse('{' + arr.join() + '}',
|
||||||
|
function (key, value) {
|
||||||
|
return key === "" ? value : decodeURIComponent(value)
|
||||||
|
}
|
||||||
|
) : {}
|
||||||
|
|
||||||
|
isValid = qp.state === sentState
|
||||||
|
|
||||||
|
if ((
|
||||||
|
oauth2.auth.schema.get("flow") === "accessCode"||
|
||||||
|
oauth2.auth.schema.get("flow") === "authorizationCode"
|
||||||
|
) && !oauth2.auth.code) {
|
||||||
|
if (!isValid) {
|
||||||
|
oauth2.errCb({
|
||||||
|
authId: oauth2.auth.name,
|
||||||
|
source: "auth",
|
||||||
|
level: "warning",
|
||||||
|
message: "Authorization may be unsafe, passed state was changed in server Passed state wasn't returned from auth server"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (qp.code) {
|
||||||
|
delete oauth2.state;
|
||||||
|
oauth2.auth.code = qp.code;
|
||||||
|
oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
|
||||||
|
} else {
|
||||||
|
let oauthErrorMsg
|
||||||
|
if (qp.error) {
|
||||||
|
oauthErrorMsg = "["+qp.error+"]: " +
|
||||||
|
(qp.error_description ? qp.error_description+ ". " : "no accessCode received from the server. ") +
|
||||||
|
(qp.error_uri ? "More info: "+qp.error_uri : "");
|
||||||
|
}
|
||||||
|
|
||||||
|
oauth2.errCb({
|
||||||
|
authId: oauth2.auth.name,
|
||||||
|
source: "auth",
|
||||||
|
level: "error",
|
||||||
|
message: oauthErrorMsg || "[Authorization failed]: no accessCode received from the server"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid, redirectUrl: redirectUrl});
|
||||||
|
}
|
||||||
|
window.close();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"name": "swagger-ui-dist",
|
||||||
|
"version": "3.27.0",
|
||||||
|
"main": "index.js",
|
||||||
|
"repository": "git@github.com:swagger-api/swagger-ui.git",
|
||||||
|
"contributors": [
|
||||||
|
"(in alphabetical order)",
|
||||||
|
"Anna Bodnia <anna.bodnia@gmail.com>",
|
||||||
|
"Buu Nguyen <buunguyen@gmail.com>",
|
||||||
|
"Josh Ponelat <jponelat@gmail.com>",
|
||||||
|
"Kyle Shockey <kyleshockey1@gmail.com>",
|
||||||
|
"Robert Barnwell <robert@robertismy.name>",
|
||||||
|
"Sahar Jafari <shr.jafari@gmail.com>"
|
||||||
|
],
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {},
|
||||||
|
"devDependencies": {}
|
||||||
|
}
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
5
pom.xml
5
pom.xml
|
|
@ -326,6 +326,11 @@
|
||||||
<artifactId>jacoco-maven-plugin</artifactId>
|
<artifactId>jacoco-maven-plugin</artifactId>
|
||||||
<version>0.8.3</version>
|
<version>0.8.3</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>io.openapitools.swagger</groupId>
|
||||||
|
<artifactId>swagger-maven-plugin</artifactId>
|
||||||
|
<version>2.1.2</version>
|
||||||
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.wildfly.plugins</groupId>
|
<groupId>org.wildfly.plugins</groupId>
|
||||||
<artifactId>wildfly-maven-plugin</artifactId>
|
<artifactId>wildfly-maven-plugin</artifactId>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue