diff --git a/document/api/README.md b/document/api/README.md new file mode 100644 index 00000000..7acef4a9 --- /dev/null +++ b/document/api/README.md @@ -0,0 +1,27 @@ +[webapi.yaml](webapi.yaml) is the web API yaml file for [swagger](https://swagger.io/). + +## Quickstart + +By the following steps, you can test APIs by the swagger editor. +In this manual, we run knowledge and swagger editor under `http://localhost` to avoid CORS. + +- deploy knowledge by `launch.sh`. + - assume you can access knowledge by http://172.20.0.1:8080/knowledge +- deploy swagger + - `docker run --rm -d swaggerapi/swagger-editor` + - assume you can access the swagger editor by http://172.17.0.2:8080 +- run nginx reverse proxy + - edit `default.conf` and modify the IP addresses of both containers. + - run nginx reverse proxy + +```bash +docker run --rm -it -p 80:80 -v `pwd`/default.conf:/etc/nginx/conf.d/default.conf +``` + +If everything is OK, you can access knowledge by `http://localhost/knowledge` and swagger editor by `http://localhost`. + +Finally, create and set access token. + +- In knowledge, create an access token. +- Open the swagger editor, and paste webapi.yaml. +- Set the access token from the `Authorize` button in the right tab of the swagger editor. diff --git a/document/api/default.conf b/document/api/default.conf new file mode 100644 index 00000000..7969f813 --- /dev/null +++ b/document/api/default.conf @@ -0,0 +1,24 @@ +server { + listen 80; + server_name localhost; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } + + location ~ ^/knowledge { + proxy_pass http://172.20.0.1:8080; + } + + location ~ ^/swagger { + rewrite /swagger(.*) $1 break; + proxy_pass http://172.17.0.2:8080; + } +} + diff --git a/document/api/webapi.yaml b/document/api/webapi.yaml index 83f27134..5682df92 100644 --- a/document/api/webapi.yaml +++ b/document/api/webapi.yaml @@ -4,7 +4,7 @@ info: description: "[Knowledge](https://github.com/support-project/knowledge) web API." version: "1.13.1" servers: - - url: http://localhost:8080/knowledge + - url: http://localhost/knowledge description: change me paths: "/api/sample": @@ -159,7 +159,7 @@ paths: name: type: string description: title - "/api/knowledge/{knowledge_id}": + "/api/knowledges/{knowledge_id}": get: description: "Get knowledge" tags: @@ -281,9 +281,19 @@ components: User: type: "object" properties: - id: + insertDatetime: + type: string + format: datetime + insertUser: + type: integer + updateDatetime: + type: string + format: datetime + updateUser: + type: integer + userId: type: integer - name: + userName: type: string Members: type: object @@ -423,6 +433,10 @@ components: type: string viewers: $ref: '#/components/schemas/Members' + required: + - content + - template + - title securitySchemes: ApiKeyAuth: type: apiKey @@ -430,4 +444,3 @@ components: name: private_token security: - ApiKeyAuth: [] -