Initial commit

This commit is contained in:
ycc
2023-03-07 13:29:08 +01:00
parent 82b69faa5f
commit 590d655d58
32 changed files with 2114 additions and 4 deletions

BIN
swagger/favicon-16x16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 665 B

BIN
swagger/favicon-32x32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 628 B

60
swagger/index.html Normal file
View File

@@ -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" charset="UTF-8"> </script>
<script src="./swagger-ui-standalone-preset.js" charset="UTF-8"> </script>
<script>
window.onload = function() {
// Begin Swagger UI call region
const ui = SwaggerUIBundle({
url: "http://127.0.0.1:8080/swagger/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>

View File

@@ -0,0 +1,79 @@
<!doctype html>
<html lang="en-US">
<head>
<title>Swagger UI: OAuth2 Redirect</title>
</head>
<body>
<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.schema.get("flow") === "authorization_code"
) && !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();
}
if (document.readyState !== 'loading') {
run();
} else {
document.addEventListener('DOMContentLoaded', function () {
run();
});
}
</script>
</body>
</html>

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

4
swagger/swagger-ui.css Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
swagger/swagger-ui.js Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

268
swagger/swagger.json Normal file
View File

@@ -0,0 +1,268 @@
{
"swagger": "2.0",
"info": {
"title": "beego Test API",
"description": "beego has a very cool tools to autogenerate documents for your API\n",
"version": "1.0.0",
"termsOfService": "http://beego.me/",
"contact": {
"email": "astaxie@gmail.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"basePath": "/oc",
"paths": {
"/identity/": {
"get": {
"tags": [
"identity"
],
"description": "get Identity\n\u003cbr\u003e",
"operationId": "IdentityController.Get",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/models.Identity"
}
}
}
},
"post": {
"tags": [
"identity"
],
"description": "create identitys\n\u003cbr\u003e",
"operationId": "IdentityController.CreateIdentity",
"parameters": [
{
"in": "body",
"name": "body",
"description": "body for identity content",
"required": true,
"schema": {
"$ref": "#/definitions/models.Identity"
}
}
],
"responses": {
"200": {
"description": "{int} models.Identity.Id"
},
"403": {
"description": "body is empty"
}
}
}
},
"/peer/": {
"get": {
"tags": [
"peer"
],
"description": "get all peers\n\u003cbr\u003e",
"operationId": "PeerController.GetAll",
"responses": {
"200": {
"description": ""
}
}
},
"post": {
"tags": [
"peer"
],
"description": "create peer\n\u003cbr\u003e",
"operationId": "PeerController.Create",
"parameters": [
{
"in": "body",
"name": "body",
"description": "The peer content",
"required": true,
"schema": {
"$ref": "#/definitions/models.Peer"
}
}
],
"responses": {
"200": {
"description": "{string} models.Peer.Id"
},
"403": {
"description": "body is empty"
}
}
}
},
"/peer/{peerId}": {
"get": {
"tags": [
"peer"
],
"description": "find peer by peerid\n\u003cbr\u003e",
"operationId": "PeerController.Get",
"parameters": [
{
"in": "path",
"name": "peerId",
"description": "the peerid you want to get",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "{peer} models.Peer"
},
"403": {
"description": ":peerId is empty"
}
}
},
"put": {
"tags": [
"peer"
],
"description": "update the peer\n\u003cbr\u003e",
"operationId": "PeerController.Update",
"parameters": [
{
"in": "path",
"name": "peerId",
"description": "The peerid you want to update",
"required": true,
"type": "string"
},
{
"in": "body",
"name": "body",
"description": "The body",
"required": true,
"schema": {
"$ref": "#/definitions/models.Peer"
}
}
],
"responses": {
"200": {
"description": "{peer} models.Peer"
},
"403": {
"description": ":peerId is empty"
}
}
},
"delete": {
"tags": [
"peer"
],
"description": "delete the peer\n\u003cbr\u003e",
"operationId": "PeerController.Delete",
"parameters": [
{
"in": "path",
"name": "peerId",
"description": "The peerId you want to delete",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "{string} delete success!"
},
"403": {
"description": "peerId is empty"
}
}
}
},
"/version/": {
"get": {
"tags": [
"version"
],
"description": "get version\n\u003cbr\u003e",
"operationId": "VersionController.GetAll",
"responses": {
"200": {
"description": ""
}
}
}
}
},
"definitions": {
"models.Identity": {
"title": "Identity",
"type": "object",
"properties": {
"Id": {
"type": "string"
},
"Name": {
"type": "string"
},
"PublicKey": {
"type": "string"
},
"Url": {
"type": "string"
}
}
},
"models.Peer": {
"title": "Peer",
"type": "object",
"properties": {
"api_version": {
"type": "string"
},
"keywords": {
"type": "array",
"items": {
"type": "string"
}
},
"last_seen_online": {
"type": "string",
"format": "datetime"
},
"name": {
"type": "string"
},
"peer_id": {
"type": "string"
},
"public_key": {
"type": "string"
},
"score": {
"type": "integer",
"format": "int64"
},
"url": {
"type": "string"
}
}
}
},
"tags": [
{
"name": "peer",
"description": "Operations about peer\n"
},
{
"name": "identity",
"description": "Operations about Identitys\n"
},
{
"name": "version",
"description": "VersionController operations for Version\n"
}
]
}

195
swagger/swagger.yml Normal file
View File

@@ -0,0 +1,195 @@
swagger: "2.0"
info:
title: beego Test API
description: |
beego has a very cool tools to autogenerate documents for your API
version: 1.0.0
termsOfService: http://beego.me/
contact:
email: astaxie@gmail.com
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
basePath: /oc
paths:
/identity/:
get:
tags:
- identity
description: |-
get Identity
<br>
operationId: IdentityController.Get
responses:
"200":
description: ""
schema:
$ref: '#/definitions/models.Identity'
post:
tags:
- identity
description: |-
create identitys
<br>
operationId: IdentityController.CreateIdentity
parameters:
- in: body
name: body
description: body for identity content
required: true
schema:
$ref: '#/definitions/models.Identity'
responses:
"200":
description: '{int} models.Identity.Id'
"403":
description: body is empty
/peer/:
get:
tags:
- peer
description: |-
get all peers
<br>
operationId: PeerController.GetAll
responses:
"200":
description: ""
post:
tags:
- peer
description: |-
create peer
<br>
operationId: PeerController.Create
parameters:
- in: body
name: body
description: The peer content
required: true
schema:
$ref: '#/definitions/models.Peer'
responses:
"200":
description: '{string} models.Peer.Id'
"403":
description: body is empty
/peer/{peerId}:
get:
tags:
- peer
description: |-
find peer by peerid
<br>
operationId: PeerController.Get
parameters:
- in: path
name: peerId
description: the peerid you want to get
required: true
type: string
responses:
"200":
description: '{peer} models.Peer'
"403":
description: :peerId is empty
put:
tags:
- peer
description: |-
update the peer
<br>
operationId: PeerController.Update
parameters:
- in: path
name: peerId
description: The peerid you want to update
required: true
type: string
- in: body
name: body
description: The body
required: true
schema:
$ref: '#/definitions/models.Peer'
responses:
"200":
description: '{peer} models.Peer'
"403":
description: :peerId is empty
delete:
tags:
- peer
description: |-
delete the peer
<br>
operationId: PeerController.Delete
parameters:
- in: path
name: peerId
description: The peerId you want to delete
required: true
type: string
responses:
"200":
description: '{string} delete success!'
"403":
description: peerId is empty
/version/:
get:
tags:
- version
description: |-
get version
<br>
operationId: VersionController.GetAll
responses:
"200":
description: ""
definitions:
models.Identity:
title: Identity
type: object
properties:
Id:
type: string
Name:
type: string
PublicKey:
type: string
Url:
type: string
models.Peer:
title: Peer
type: object
properties:
api_version:
type: string
keywords:
type: array
items:
type: string
last_seen_online:
type: string
format: datetime
name:
type: string
peer_id:
type: string
public_key:
type: string
score:
type: integer
format: int64
url:
type: string
tags:
- name: peer
description: |
Operations about peer
- name: identity
description: |
Operations about Identitys
- name: version
description: |
VersionController operations for Version