initiate swagger doc for Exchange web app

This commit is contained in:
marjuqi@ad
2022-05-17 11:03:44 +07:00
parent 29ab59bbf7
commit d5e8541c64
9 changed files with 400 additions and 1 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 665 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 628 B

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
+82
View File
@@ -0,0 +1,82 @@
<!-- 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-assets/swagger-ui.css" />
<link rel="icon" type="image/png" href="./swagger-assets/favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="./swagger-assets/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-assets/swagger-ui-bundle.js" charset="UTF-8"> </script>
<script src="./swagger-assets/swagger-ui-standalone-preset.js" charset="UTF-8"> </script>
<script>
window.onload = function() {
// Begin Swagger UI call region
const ui = SwaggerUIBundle({
url: "{{ env('APP_URL') }}/swagger/json",
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
responseInterceptor:
function (response) {
console.log('Response');
console.log(response.obj);
if (response.obj.payload) {
if (response.obj.payload.access_token) {
const token = response.obj.payload.access_token;
console.log("Auth Token: " + token);
localStorage.setItem("token", token)
}
return response;
}
},
requestInterceptor:
function (request) {
console.log('Request');
console.log(request);
if( request.url.indexOf('login') < 0 && request.url.indexOf('swagger/json') < 0) {
request.headers.Authorization = "Bearer " + localStorage.getItem("token");
}
return request;
},
layout: "StandaloneLayout"
});
// End Swagger UI call region
window.ui = ui;
};
</script>
</body>
</html>
+294
View File
@@ -0,0 +1,294 @@
{
"swagger": "2.0",
"info": {
"description": Exchange web app",
"version": "1.0.0",
"title": "Exchange web app"
},
"host": "{{request()->getHttpHost()}}",
"basePath": "/api/v1",
"tags": [
{
"name": "Address",
"description": "Endpoints related to address module, e.g. create, district."
}
],
"schemes": [
"http",
"https"
],
"paths": {
"/address/create": {
"post": {
"tags": [
"Address"
],
"produces": [
"application/json"
],
"operationId": "createAddress",
"summary": "Create address",
"description": "",
"parameters": [
{
"name": "company_id",
"in": "query",
"description": "Company id",
"required": true,
"type": "integer"
},
{
"name": "district_id",
"in": "query",
"description": "District id",
"required": true,
"type": "integer"
},
{
"name": "street_one",
"in": "query",
"description": "Address line 1",
"required": true,
"type": "string"
},
{
"name": "street_two",
"in": "query",
"description": "Address line 2",
"required": true,
"type": "string"
},
{
"name": "post_code",
"in": "query",
"description": "Postcode of the address",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "successful operation",
"headers": {
"X-Expires-After": {
"type": "string",
"format": "date-time",
"description": "date in UTC when token expires"
},
"X-Rate-Limit": {
"type": "integer",
"format": "int32",
"description": "calls per hour allowed by the user"
}
},
"schema": {
"type": "string"
}
},
"422": {
"description": "Invalid input supplied"
}
}
}
},
"/address/delete/{id}": {
"delete": {
"tags": [
"Address"
],
"produces": [
"application/json"
],
"operationId": "deleteAddress",
"summary": "Delete address",
"description": "",
"parameters": [
{
"name": "id",
"in": "path",
"description": "District id",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "successful operation",
"headers": {
"X-Expires-After": {
"type": "string",
"format": "date-time",
"description": "date in UTC when token expires"
},
"X-Rate-Limit": {
"type": "integer",
"format": "int32",
"description": "calls per hour allowed by the user"
}
},
"schema": {
"type": "string"
}
},
"422": {
"description": "Invalid input supplied"
}
}
}
},
"/address/list": {
"get": {
"tags": [
"Address"
],
"produces": [
"application/json"
],
"operationId": "listAddress",
"summary": "List addresses of logged in user",
"description": "",
"parameters": [
{
"name": "filter",
"in": "query",
"description": "Filters",
"required": false,
"type": "array",
"items": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "successful operation",
"headers": {
"X-Expires-After": {
"type": "string",
"format": "date-time",
"description": "date in UTC when token expires"
},
"X-Rate-Limit": {
"type": "integer",
"format": "int32",
"description": "calls per hour allowed by the user"
}
},
"schema": {
"type": "string"
}
},
"422": {
"description": "Invalid input supplied"
}
}
}
},
"/address/{id}/show": {
"get": {
"tags": [
"Address"
],
"produces": [
"application/json"
],
"operationId": "showAddress",
"summary": "List addresses of logged in user",
"description": "",
"parameters": [
{
"name": "id",
"in": "path",
"description": "Address id",
"required": true,
"type": "integer"
}
],
"responses": {
"200": {
"description": "successful operation",
"headers": {
"X-Expires-After": {
"type": "string",
"format": "date-time",
"description": "date in UTC when token expires"
},
"X-Rate-Limit": {
"type": "integer",
"format": "int32",
"description": "calls per hour allowed by the user"
}
},
"schema": {
"type": "string"
}
},
"422": {
"description": "Invalid input supplied"
}
}
}
},
"/address/update/{id}": {
"put": {
"tags": [
"Address"
],
"produces": [
"application/json"
],
"operationId": "updateAddress",
"summary": "Set default address",
"description": "",
"parameters": [
{
"name": "id",
"in": "path",
"description": "Address id",
"required": true,
"type": "integer"
}
],
"responses": {
"200": {
"description": "successful operation",
"headers": {
"X-Expires-After": {
"type": "string",
"format": "date-time",
"description": "date in UTC when token expires"
},
"X-Rate-Limit": {
"type": "integer",
"format": "int32",
"description": "calls per hour allowed by the user"
}
},
"schema": {
"type": "string"
}
},
"422": {
"description": "Invalid input supplied"
}
}
}
}
},
"securityDefinitions": {
"Authorization": {
"type": "apiKey",
"name": "api_key",
"in": "header"
},
"petstore_auth": {
"type": "oauth2",
"authorizationUrl": "https://petstore.swagger.io/oauth/authorize",
"flow": "implicit",
"scopes": {
"read:pets": "read your pets",
"write:pets": "modify pets in your account"
}
}
}
}
+10
View File
@@ -191,3 +191,13 @@ Route::get('purchase/sensitive/', function(Request $request){
});
Route::get('/transactions/supplier/{id}/mock_up', 'Transactions\DownloadMockUpWhiteFormPdfController@download')->name('whiteForm.mockUp');
Route::group(['prefix' => 'swagger'], function () {
Route::get('/', function () {
return view('swagger.index');
});
Route::get('/json', function () {
return view('swagger.json');
});
});