-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Manual swagger documentation generation
- Loading branch information
Bernard Labno
committed
Aug 6, 2019
1 parent
3798e63
commit f5157a2
Showing
10 changed files
with
478 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
{ | ||
"openapi": "3.0.1", | ||
"info": { | ||
"title": "Bisq HTTP API", | ||
"version": "0.0.1" | ||
}, | ||
"security": [ | ||
{ | ||
"authorization": [] | ||
} | ||
], | ||
"tags": [ | ||
{ | ||
"name": "user" | ||
}, | ||
{ | ||
"name": "version" | ||
} | ||
], | ||
"paths": { | ||
"/api/v1/user/authenticate": { | ||
"post": { | ||
"tags": [ | ||
"user" | ||
], | ||
"summary": "Exchange password for access token", | ||
"operationId": "authenticate", | ||
"requestBody": { | ||
"content": { | ||
"application/json": { | ||
"schema": { | ||
"$ref": "#/components/schemas/AuthForm" | ||
} | ||
} | ||
} | ||
}, | ||
"responses": { | ||
"default": { | ||
"content": { | ||
"application/json": { | ||
"schema": { | ||
"$ref": "#/components/schemas/AuthResult" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"/api/v1/user/password": { | ||
"post": { | ||
"tags": [ | ||
"user" | ||
], | ||
"summary": "Change password", | ||
"operationId": "changePassword", | ||
"requestBody": { | ||
"content": { | ||
"application/json": { | ||
"schema": { | ||
"$ref": "#/components/schemas/ChangePassword" | ||
} | ||
} | ||
} | ||
}, | ||
"responses": { | ||
"default": { | ||
"content": { | ||
"application/json": { | ||
"schema": { | ||
"$ref": "#/components/schemas/AuthResult" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"/api/v1/version": { | ||
"get": { | ||
"tags": [ | ||
"version" | ||
], | ||
"summary": "Get version details", | ||
"operationId": "getVersionDetails", | ||
"responses": { | ||
"default": { | ||
"description": "default response", | ||
"content": { | ||
"application/json": { | ||
"schema": { | ||
"$ref": "#/components/schemas/VersionDetails" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"components": { | ||
"schemas": { | ||
"AuthResult": { | ||
"type": "object", | ||
"properties": { | ||
"token": { | ||
"type": "string" | ||
} | ||
} | ||
}, | ||
"AuthForm": { | ||
"type": "object", | ||
"properties": { | ||
"password": { | ||
"type": "string" | ||
} | ||
} | ||
}, | ||
"ChangePassword": { | ||
"type": "object", | ||
"properties": { | ||
"newPassword": { | ||
"type": "string" | ||
}, | ||
"oldPassword": { | ||
"type": "string" | ||
} | ||
} | ||
}, | ||
"VersionDetails": { | ||
"type": "object", | ||
"properties": { | ||
"application": { | ||
"type": "string" | ||
}, | ||
"network": { | ||
"type": "integer", | ||
"format": "int32" | ||
}, | ||
"p2PMessage": { | ||
"type": "integer", | ||
"format": "int32" | ||
}, | ||
"localDB": { | ||
"type": "integer", | ||
"format": "int32" | ||
}, | ||
"tradeProtocol": { | ||
"type": "integer", | ||
"format": "int32" | ||
} | ||
} | ||
} | ||
}, | ||
"securitySchemes": { | ||
"authorization": { | ||
"type": "apiKey", | ||
"name": "authorization", | ||
"in": "header" | ||
} | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<!-- 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> | ||
window.onload = function() { | ||
// Begin Swagger UI call region | ||
const ui = SwaggerUIBundle({ | ||
url: "/openapi.json", | ||
dom_id: '#swagger-ui', | ||
deepLinking: true, | ||
presets: [ | ||
SwaggerUIBundle.presets.apis | ||
], | ||
plugins: [ | ||
SwaggerUIBundle.plugins.DownloadUrl | ||
], | ||
layout: "BaseLayout" | ||
}); | ||
// End Swagger UI call region | ||
|
||
window.ui = ui | ||
} | ||
</script> | ||
</body> | ||
</html> |
98 changes: 98 additions & 0 deletions
98
api/src/main/resources/META-INF/swagger/ui/swagger-ui-bundle.js
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
api/src/test/java/bisq/api/http/service/auth/SwaggerGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* This file is part of Bisq. | ||
* | ||
* Bisq is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or (at | ||
* your option) any later version. | ||
* | ||
* Bisq is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public | ||
* License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package bisq.api.http.service.auth; | ||
|
||
import bisq.api.http.service.HttpApiInterfaceV1; | ||
|
||
|
||
|
||
import io.swagger.v3.core.util.Json; | ||
import io.swagger.v3.jaxrs2.Reader; | ||
import io.swagger.v3.oas.integration.SwaggerConfiguration; | ||
import io.swagger.v3.oas.models.OpenAPI; | ||
|
||
public class SwaggerGenerator { | ||
|
||
public static void main(String[] args) { | ||
Reader reader = new Reader(new SwaggerConfiguration()); | ||
OpenAPI openAPI = reader.read(HttpApiInterfaceV1.class); | ||
System.out.println(Json.pretty(openAPI)); | ||
} | ||
} |
Oops, something went wrong.