Skip to content

Commit

Permalink
Add README and update yaml to get HTTP 200 response
Browse files Browse the repository at this point in the history
  • Loading branch information
y-okumura-isp committed Apr 7, 2021
1 parent c3ab924 commit c5eb93b
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 5 deletions.
27 changes: 27 additions & 0 deletions document/api/README.md
Original file line number Diff line number Diff line change
@@ -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.
24 changes: 24 additions & 0 deletions document/api/default.conf
Original file line number Diff line number Diff line change
@@ -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;
}
}

23 changes: 18 additions & 5 deletions document/api/webapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down Expand Up @@ -159,7 +159,7 @@ paths:
name:
type: string
description: title
"/api/knowledge/{knowledge_id}":
"/api/knowledges/{knowledge_id}":
get:
description: "Get knowledge"
tags:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -423,11 +433,14 @@ components:
type: string
viewers:
$ref: '#/components/schemas/Members'
required:
- content
- template
- title
securitySchemes:
ApiKeyAuth:
type: apiKey
in: query
name: private_token
security:
- ApiKeyAuth: []

0 comments on commit c5eb93b

Please sign in to comment.