You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@answer.apache.org by li...@apache.org on 2024/01/18 03:18:59 UTC
(incubator-answer-website) 01/01: docs(api): add api document #143
This is an automated email from the ASF dual-hosted git repository.
linkinstar pushed a commit to branch docs/api
in repository https://gitbox.apache.org/repos/asf/incubator-answer-website.git
commit a120e863dd7a08230bdb693a0a8501492e03fd53
Author: LinkinStars <li...@foxmail.com>
AuthorDate: Thu Jan 18 11:18:47 2024 +0800
docs(api): add api document #143
---
docs/development/api.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++
sidebars.js | 1 +
2 files changed, 47 insertions(+)
diff --git a/docs/development/api.md b/docs/development/api.md
new file mode 100644
index 00000000..ac53a919
--- /dev/null
+++ b/docs/development/api.md
@@ -0,0 +1,46 @@
+---
+slug: /api
+---
+
+# API Document
+
+:::tip
+
+Answer using swagger to generate API document automatically. Swagger can display the API document in a friendly way, and can also provide a convenient way to test the API.
+
+:::
+
+## Where is the API document?
+
+### Quick Look
+If you want to quickly view the API document, you can visit the following link:
+https://meta.answer.dev/swagger/index.html
+
+### View your own API document
+If you already have an Answer instance, you can view the API document of your own instance by visiting the following link:
+https://example.com/swagger/index.html
+
+If you can't access the above link, please check the following configuration items whether they are configured correctly.
+
+```yaml title="/data/conf/config.yaml"
+swaggerui:
+ show: true
+ protocol: http
+ host: 127.0.0.1
+ address: ':9080' # leave blank to use the 80 port number
+```
+
+## Generate API document
+
+Answer using [swag](https://github.com/swaggo/swag) to generate API document json/yaml file automatically according to the comments in the code. You can use the following steps to generate API document.
+
+```bash
+# install swag cli
+$ go install github.com/swaggo/swag/cmd/swag@latest
+
+# enter the project root directory and execute the following command
+$ cd script
+$ ./gen-api.sh
+
+# the generated documentation is in the docs/api directory
+```
\ No newline at end of file
diff --git a/sidebars.js b/sidebars.js
index 80492a1d..16c2e5ab 100644
--- a/sidebars.js
+++ b/sidebars.js
@@ -67,6 +67,7 @@ module.exports = {
collapsed: true,
items: [
'development/database',
+ 'development/api',
],
},
'notice',