feat: add openapi design doc
This commit is contained in:
parent
bffe41a012
commit
02ed6be314
4 changed files with 187 additions and 0 deletions
15
Caddyfile
Normal file
15
Caddyfile
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
http://localhost
|
||||||
|
|
||||||
|
route /api/v1/* {
|
||||||
|
uri strip_prefix /api/v1
|
||||||
|
reverse_proxy app
|
||||||
|
}
|
||||||
|
|
||||||
|
route /docs/* {
|
||||||
|
uri strip_prefix /docs
|
||||||
|
file_server {
|
||||||
|
root /usr/share/caddy/www/design
|
||||||
|
index index.html
|
||||||
|
browse true
|
||||||
|
}
|
||||||
|
}
|
||||||
17
design/index.html
Normal file
17
design/index.html
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
|
<title>Scullion REST API</title>
|
||||||
|
<script src="https://unpkg.com/@stoplight/elements/web-components.min.js"></script>
|
||||||
|
<link rel="stylesheet" href="https://unpkg.com/@stoplight/elements/styles.min.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<elements-api
|
||||||
|
apiDescriptionUrl="http://localhost:8080/docs/openapi.yml"
|
||||||
|
router="hash"
|
||||||
|
layout="sidebar"
|
||||||
|
/>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
144
design/openapi.yml
Normal file
144
design/openapi.yml
Normal file
|
|
@ -0,0 +1,144 @@
|
||||||
|
openapi: "3.0.3"
|
||||||
|
info:
|
||||||
|
title: sfu
|
||||||
|
version: 0.1.0
|
||||||
|
description: file upload server
|
||||||
|
servers:
|
||||||
|
- url: http://localhost:8080/api/v1/
|
||||||
|
description: local server
|
||||||
|
paths:
|
||||||
|
/:
|
||||||
|
get:
|
||||||
|
summary: "list all uploaded files"
|
||||||
|
description: "list all uploaded files"
|
||||||
|
operationId: "list_files"
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: "file list successful"
|
||||||
|
content:
|
||||||
|
text/plain:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
format: uri
|
||||||
|
|
||||||
|
500:
|
||||||
|
description: "internal server error"
|
||||||
|
content:
|
||||||
|
text/plain:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
default: "internal server error"
|
||||||
|
post:
|
||||||
|
summary: "upload file"
|
||||||
|
description: "uploaded a file"
|
||||||
|
operationId: "upload_file"
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
multipart/form-data:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
file:
|
||||||
|
type: string
|
||||||
|
format: binary
|
||||||
|
description: "file to upload"
|
||||||
|
parameters:
|
||||||
|
- name: force
|
||||||
|
in: query
|
||||||
|
description: "force upload file which may overwrite an existing file with the same name"
|
||||||
|
required: false
|
||||||
|
schema:
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
responses:
|
||||||
|
201:
|
||||||
|
description: "file upload successful"
|
||||||
|
content:
|
||||||
|
text/plain:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
409:
|
||||||
|
description: "file already exists"
|
||||||
|
content:
|
||||||
|
text/plain:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
default: "file already exists"
|
||||||
|
500:
|
||||||
|
description: "internal server error"
|
||||||
|
content:
|
||||||
|
text/plain:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
default: "internal server error"
|
||||||
|
/{file_name}:
|
||||||
|
get:
|
||||||
|
summary: "get file"
|
||||||
|
description: "get file"
|
||||||
|
operationId: "get_file"
|
||||||
|
parameters:
|
||||||
|
- name: file_name
|
||||||
|
in: path
|
||||||
|
description: "file name"
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: "file download successful"
|
||||||
|
content:
|
||||||
|
text/plain:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
format: binary
|
||||||
|
404:
|
||||||
|
description: "file not found"
|
||||||
|
content:
|
||||||
|
text/plain:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
default: "file not found"
|
||||||
|
500:
|
||||||
|
description: "internal server error"
|
||||||
|
content:
|
||||||
|
text/plain:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
default: "internal server error"
|
||||||
|
delete:
|
||||||
|
summary: "delete file"
|
||||||
|
description: "delete file"
|
||||||
|
operationId: "delete_file"
|
||||||
|
parameters:
|
||||||
|
- name: file_name
|
||||||
|
in: path
|
||||||
|
description: "file name"
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: "file delete successful"
|
||||||
|
content:
|
||||||
|
text/plain:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
default: "file delete successful"
|
||||||
|
404:
|
||||||
|
description: "file not found"
|
||||||
|
content:
|
||||||
|
text/plain:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
default: "file not found"
|
||||||
|
500:
|
||||||
|
description: "internal server error"
|
||||||
|
content:
|
||||||
|
text/plain:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
default: "internal server error"
|
||||||
11
logger.go
Normal file
11
logger.go
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
var Info = log.New(os.Stdout, "\u001b[34mINFO: \u001B[0m", log.LstdFlags|log.Lshortfile)
|
||||||
|
var Warning = log.New(os.Stdout, "\u001b[33mWARNING: \u001B[0m", log.LstdFlags|log.Lshortfile)
|
||||||
|
var Error = log.New(os.Stdout, "\u001b[31mERROR: \u001b[0m", log.LstdFlags|log.Lshortfile)
|
||||||
|
var Debug = log.New(os.Stdout, "\u001b[36mDEBUG: \u001B[0m", log.LstdFlags|log.Lshortfile)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue