Add Swagger static document generation
Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
@@ -180,6 +180,48 @@
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.github.kongchen</groupId>
|
||||
<artifactId>swagger-maven-plugin</artifactId>
|
||||
<version>3.1.8</version>
|
||||
<configuration>
|
||||
<apiSources>
|
||||
<apiSource>
|
||||
<springmvc>true</springmvc>
|
||||
<locations>
|
||||
<location>net.runelite</location>
|
||||
</locations>
|
||||
<schemes>
|
||||
<scheme>https</scheme>
|
||||
</schemes>
|
||||
<host>api.runelite.net</host>
|
||||
<basePath>/runelite-${project.version}</basePath>
|
||||
<info>
|
||||
<title>${project.parent.name} HTTP API</title>
|
||||
<version>${project.version}</version>
|
||||
<description>${project.description}</description>
|
||||
<license>
|
||||
<url>https://tldrlegal.com/license/bsd-2-clause-license-(freebsd)</url>
|
||||
<name>BSD 2-Clause "Simplified"</name>
|
||||
</license>
|
||||
</info>
|
||||
<templatePath>${basedir}/src/main/templates/template.html.hbs</templatePath>
|
||||
<swaggerDirectory>${project.build.directory}/swagger-ui</swaggerDirectory>
|
||||
<outputPath>${project.build.directory}/site/api.html</outputPath>
|
||||
<attachSwaggerArtifact>true</attachSwaggerArtifact>
|
||||
<outputFormats>json</outputFormats>
|
||||
</apiSource>
|
||||
</apiSources>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>generate</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
110
http-service/src/main/templates/markdown.hbs
Normal file
110
http-service/src/main/templates/markdown.hbs
Normal file
@@ -0,0 +1,110 @@
|
||||
{{#info}}
|
||||
# {{title}}
|
||||
{{join schemes " | "}}://{{host}}{{basePath}}
|
||||
|
||||
{{description}}
|
||||
|
||||
{{#contact}}
|
||||
[**Contact the developer**](mailto:{{email}})
|
||||
{{/contact}}
|
||||
|
||||
**Version** {{version}}
|
||||
|
||||
{{#if termsOfService}}
|
||||
[**Terms of Service**]({{termsOfService}})
|
||||
{{/if}}
|
||||
|
||||
{{/info}}
|
||||
|
||||
{{#if consumes}}__Consumes:__ {{join consumes ", "}}{{/if}}
|
||||
|
||||
{{#if produces}}__Produces:__ {{join produces ", "}}{{/if}}
|
||||
|
||||
{{#if securityDefinitions}}
|
||||
# Security Definitions
|
||||
{{> security}}
|
||||
{{/if}}
|
||||
|
||||
<details>
|
||||
<summary><b>Table Of Contents</b></summary>
|
||||
[toc]
|
||||
</details>
|
||||
|
||||
# APIs
|
||||
|
||||
{{#each paths}}
|
||||
## {{@key}}
|
||||
{{#this}}
|
||||
{{#get}}
|
||||
### GET
|
||||
{{> operation}}
|
||||
{{/get}}
|
||||
|
||||
{{#put}}
|
||||
### PUT
|
||||
{{> operation}}
|
||||
{{/put}}
|
||||
|
||||
{{#post}}
|
||||
### POST
|
||||
|
||||
{{> operation}}
|
||||
|
||||
{{/post}}
|
||||
|
||||
{{#delete}}
|
||||
### DELETE
|
||||
{{> operation}}
|
||||
{{/delete}}
|
||||
|
||||
{{#option}}
|
||||
### OPTION
|
||||
{{> operation}}
|
||||
{{/option}}
|
||||
|
||||
{{#patch}}
|
||||
### PATCH
|
||||
{{> operation}}
|
||||
{{/patch}}
|
||||
|
||||
{{#head}}
|
||||
### HEAD
|
||||
{{> operation}}
|
||||
{{/head}}
|
||||
|
||||
{{/this}}
|
||||
{{/each}}
|
||||
|
||||
# Definitions
|
||||
{{#each definitions}}
|
||||
## <a name="/definitions/{{key}}">{{@key}}</a>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>name</th>
|
||||
<th>type</th>
|
||||
<th>required</th>
|
||||
<th>description</th>
|
||||
<th>example</th>
|
||||
</tr>
|
||||
{{#each this.properties}}
|
||||
<tr>
|
||||
<td>{{@key}}</td>
|
||||
<td>
|
||||
{{#ifeq type "array"}}
|
||||
{{#items.$ref}}
|
||||
{{type}}[<a href="{{items.$ref}}">{{basename items.$ref}}</a>]
|
||||
{{/items.$ref}}
|
||||
{{^items.$ref}}{{type}}[{{items.type}}]{{/items.$ref}}
|
||||
{{else}}
|
||||
{{#$ref}}<a href="{{$ref}}">{{basename $ref}}</a>{{/$ref}}
|
||||
{{^$ref}}{{type}}{{#format}} ({{format}}){{/format}}{{/$ref}}
|
||||
{{/ifeq}}
|
||||
</td>
|
||||
<td>{{#required}}required{{/required}}{{^required}}optional{{/required}}</td>
|
||||
<td>{{#description}}{{{description}}}{{/description}}{{^description}}-{{/description}}</td>
|
||||
<td>{{example}}</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</table>
|
||||
{{/each}}
|
||||
71
http-service/src/main/templates/operation.hbs
Normal file
71
http-service/src/main/templates/operation.hbs
Normal file
@@ -0,0 +1,71 @@
|
||||
{{#deprecated}}-deprecated-{{/deprecated}}
|
||||
<a id="{{operationId}}">{{summary}}</a>
|
||||
|
||||
{{description}}
|
||||
|
||||
{{#if externalDocs.url}}{{externalDocs.description}}. [See external documents for more details]({{externalDocs.url}})
|
||||
{{/if}}
|
||||
|
||||
{{#if security}}
|
||||
#### Security
|
||||
{{/if}}
|
||||
|
||||
{{#security}}
|
||||
{{#each this}}
|
||||
* {{@key}}
|
||||
{{#this}} * {{this}}
|
||||
{{/this}}
|
||||
{{/each}}
|
||||
{{/security}}
|
||||
|
||||
#### Request
|
||||
|
||||
{{#if consumes}}__Content-Type:__ {{join consumes ", "}}{{/if}}
|
||||
|
||||
##### Parameters
|
||||
{{#if parameters}}
|
||||
<table>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Located in</th>
|
||||
<th>Required</th>
|
||||
<th>Description</th>
|
||||
<th>Default</th>
|
||||
<th>Schema</th>
|
||||
</tr>
|
||||
{{/if}}
|
||||
|
||||
{{#parameters}}
|
||||
<tr>
|
||||
<th>{{name}}</th>
|
||||
<td>{{in}}</td>
|
||||
<td>{{#if required}}yes{{else}}no{{/if}}</td>
|
||||
<td>{{description}}{{#if pattern}} (**Pattern**: `{{pattern}}`){{/if}}</td>
|
||||
<td> - </td>
|
||||
{{#ifeq in "body"}}
|
||||
<td>
|
||||
{{#ifeq schema.type "array"}}Array[<a href="{{schema.items.$ref}}">{{basename schema.items.$ref}}</a>]{{/ifeq}}
|
||||
{{#schema.$ref}}<a href="{{schema.$ref}}">{{basename schema.$ref}}</a> {{/schema.$ref}}
|
||||
</td>
|
||||
{{else}}
|
||||
{{#ifeq type "array"}}
|
||||
<td>Array[{{items.type}}] ({{collectionFormat}})</td>
|
||||
{{else}}
|
||||
<td>{{type}} {{#format}}({{format}}){{/format}}</td>
|
||||
{{/ifeq}}
|
||||
{{/ifeq}}
|
||||
</tr>
|
||||
{{/parameters}}
|
||||
{{#if parameters}}
|
||||
</table>
|
||||
{{/if}}
|
||||
|
||||
|
||||
#### Response
|
||||
|
||||
{{#if produces}}__Content-Type:__ {{join produces ", "}}{{/if}}
|
||||
|
||||
| Status Code | Reason | Response Model |
|
||||
|-------------|-------------|----------------|
|
||||
{{#each responses}}| {{@key}} | {{description}} | {{#schema.$ref}}<a href="{{schema.$ref}}">{{basename schema.$ref}}</a>{{/schema.$ref}}{{#ifeq schema.type "array"}}Array[<a href="{{schema.items.$ref}}">{{basename schema.items.$ref}}</a>]{{/ifeq}}{{^schema}} - {{/schema}}|
|
||||
{{/each}}
|
||||
88
http-service/src/main/templates/security.hbs
Normal file
88
http-service/src/main/templates/security.hbs
Normal file
@@ -0,0 +1,88 @@
|
||||
{{#each securityDefinitions}}
|
||||
### {{@key}}
|
||||
{{#this}}
|
||||
{{#ifeq type "oauth2"}}
|
||||
<table>
|
||||
<tr>
|
||||
<th>type</th>
|
||||
<th colspan="2">{{type}}</th>
|
||||
</tr>
|
||||
{{#if description}}
|
||||
<tr>
|
||||
<th>description</th>
|
||||
<th colspan="2">{{description}}</th>
|
||||
</tr>
|
||||
{{/if}}
|
||||
{{#if authorizationUrl}}
|
||||
<tr>
|
||||
<th>authorizationUrl</th>
|
||||
<th colspan="2">{{authorizationUrl}}</th>
|
||||
</tr>
|
||||
{{/if}}
|
||||
{{#if flow}}
|
||||
<tr>
|
||||
<th>flow</th>
|
||||
<th colspan="2">{{flow}}</th>
|
||||
</tr>
|
||||
{{/if}}
|
||||
{{#if tokenUrl}}
|
||||
<tr>
|
||||
<th>tokenUrl</th>
|
||||
<th colspan="2">{{tokenUrl}}</th>
|
||||
</tr>
|
||||
{{/if}}
|
||||
{{#if scopes}}
|
||||
<tr>
|
||||
<td rowspan="3">scopes</td>
|
||||
{{#each scopes}}
|
||||
<td>{{@key}}</td>
|
||||
<td>{{this}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
{{/each}}
|
||||
</tr>
|
||||
{{/if}}
|
||||
</table>
|
||||
{{/ifeq}}
|
||||
{{#ifeq type "apiKey"}}
|
||||
<table>
|
||||
<tr>
|
||||
<th>type</th>
|
||||
<th colspan="2">{{type}}</th>
|
||||
</tr>
|
||||
{{#if description}}
|
||||
<tr>
|
||||
<th>description</th>
|
||||
<th colspan="2">{{description}}</th>
|
||||
</tr>
|
||||
{{/if}}
|
||||
{{#if name}}
|
||||
<tr>
|
||||
<th>name</th>
|
||||
<th colspan="2">{{name}}</th>
|
||||
</tr>
|
||||
{{/if}}
|
||||
{{#if in}}
|
||||
<tr>
|
||||
<th>in</th>
|
||||
<th colspan="2">{{in}}</th>
|
||||
</tr>
|
||||
{{/if}}
|
||||
</table>
|
||||
{{/ifeq}}
|
||||
{{#ifeq type "basic"}}
|
||||
<table>
|
||||
<tr>
|
||||
<th>type</th>
|
||||
<th colspan="2">{{type}}</th>
|
||||
</tr>
|
||||
{{#if description}}
|
||||
<tr>
|
||||
<th>description</th>
|
||||
<th colspan="2">{{description}}</th>
|
||||
</tr>
|
||||
{{/if}}
|
||||
</table>
|
||||
{{/ifeq}}
|
||||
{{/this}}
|
||||
{{/each}}
|
||||
49
http-service/src/main/templates/template.html.hbs
Normal file
49
http-service/src/main/templates/template.html.hbs
Normal file
@@ -0,0 +1,49 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<!-- Required meta tags -->
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/3.0.1/github-markdown.min.css"/>
|
||||
<style>
|
||||
.markdown-body {
|
||||
box-sizing: border-box;
|
||||
min-width: 200px;
|
||||
max-width: 980px;
|
||||
margin: 0 auto;
|
||||
padding: 45px;
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.markdown-body {
|
||||
padding: 15px;
|
||||
}
|
||||
}
|
||||
|
||||
.markdown-body table {
|
||||
display: table;
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- JS -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/showdown/1.9.0/showdown.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/gh/JanLoebel/showdown-toc/src/showdown-toc.js"></script>
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
var markdown = document.querySelector('noscript').innerText
|
||||
var converter = new showdown.Converter({emoji: true, extensions: ['toc']})
|
||||
converter.setFlavor('github')
|
||||
var html = converter.makeHtml(markdown)
|
||||
|
||||
document.body.innerHTML = html
|
||||
})
|
||||
</script>
|
||||
|
||||
<title>{{info.title}} {{info.version}}</title>
|
||||
</head>
|
||||
<body class="markdown-body">
|
||||
<noscript>{{>markdown}}</noscript>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user