Skip to content

Add web api document #1112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: v1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}

Loading