membphis commented on a change in pull request #992: URL: https://github.com/apache/apisix-dashboard/pull/992#discussion_r539152195
########## File path: api/internal/handler/handler.go ########## @@ -1,19 +1,21 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// API doc of Manager API. Review comment: we can not delete the ASF header ########## File path: docs/FAQ.md ########## @@ -54,3 +54,21 @@ $ api/build-tools/schema-sync.sh /usr/local/apisix ``` After the command finishes executing, if you are using a binary `manager-api` that has already been built, you will need to manually copy `api/conf/schema.json` to the `conf` directory under the Dashboard **working directory**. where **working directory** refers to the `conf` directory under this [document](./deploy.md) is the `output` directory, or the directory with the modified name, that is generated in the root directory after the build is complete. + +### 5. How to write api interface documentation + +We use [go-swagger](https://github.com/go-swagger/go-swagger) to generate Swagger 2.0 documents, and then convert them to markdown format so that they can be viewed directly in the github repository. Specific steps are as follows: + +1. Write comments according to [Specification](https://goswagger.io/use/spec.html). For details, please refer to the existing example `api/internal/handler/route/route.go` in this project. + +2. Use the `go-swagger` tool to generate Swagger 2.0 documents. + +```shell +$ swagger generate spec -o ./docs/api/api.yaml --scan-models Review comment: we can move those to `Makefile` ########## File path: docs/api/api.md ########## @@ -0,0 +1,359 @@ +<!-- +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +--> + +# API doc of Manager API. +Manager API directly operates ETCD and provides data management for APISIX, provides APIs for Front-end or other clients. + +**License:** [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0) + +### /apisix/admin/check_ssl_cert + +#### POST +##### Description: + +verify SSL cert and key Review comment: The period is missing ########## File path: docs/api/api.md ########## @@ -0,0 +1,359 @@ +<!-- +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +--> + +# API doc of Manager API. +Manager API directly operates ETCD and provides data management for APISIX, provides APIs for Front-end or other clients. + +**License:** [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0) + +### /apisix/admin/check_ssl_cert + +#### POST +##### Description: + +verify SSL cert and key + +##### Parameters + +| Name | Located in | Description | Required | Schema | +| ---- | ---------- | ----------- | -------- | ---- | +| cert | body | cert of SSL | Yes | string | +| key | body | key of SSL | Yes | string | + +##### Responses + +| Code | Description | Schema | +| ---- | ----------- | ------ | +| 0 | SSL verify passed | [ApiError](#ApiError) | +| default | unexpected error | [ApiError](#ApiError) | + +### /apisix/admin/check_ssl_exists + +#### POST +##### Description: + +check SSL exists or not by sni Review comment: ditto, please fix similar points ########## File path: docs/api/api.md ########## @@ -0,0 +1,397 @@ +<!-- +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +--> + +# API doc of Manager API. +It's used to manage etcd and provide APIs to the frontend interface. + +## Version: 2.2 + +**License:** [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0) + +### /apisix/admin/check_ssl_cert + +#### POST +##### Summary: + +verify SSL cert and key + +##### Description: + +verify SSL cert and key + +##### Parameters + +| Name | Located in | Description | Required | Schema | +| ---- | ---------- | ----------- | -------- | ---- | +| cert | body | cert of SSL | Yes | string | +| key | body | key of SSL | Yes | string | + +##### Responses + +| Code | Description | Schema | +| ---- | ----------- | ------ | +| 0 | SSL verify passed | [ApiError](#ApiError) | +| default | unexpected error | [ApiError](#ApiError) | + +### /apisix/admin/check_ssl_exists + +#### POST +##### Summary: + +check SSL exists or not + +##### Description: + +check SSL exists or not by sni + +##### Parameters + +| Name | Located in | Description | Required | Schema | +| ---- | ---------- | ----------- | -------- | ---- | +| cert | body | cert of SSL | Yes | string | +| key | body | key of SSL | Yes | string | + +##### Responses + +| Code | Description | Schema | +| ---- | ----------- | ------ | +| 0 | SSL exists | [ApiError](#ApiError) | +| default | unexpected error | [ApiError](#ApiError) | + +### /apisix/admin/consumers + +#### GET +##### Summary: + +Returns consumer list + +##### Description: + +Return the consumer list according to the specified page number and page size, and can search by username Review comment: `and can search by username` to `and support to search "consumer" by username` ########## File path: docs/api/api.md ########## @@ -0,0 +1,359 @@ +<!-- +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +--> + +# API doc of Manager API. +Manager API directly operates ETCD and provides data management for APISIX, provides APIs for Front-end or other clients. + +**License:** [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0) + +### /apisix/admin/check_ssl_cert + +#### POST +##### Description: + +verify SSL cert and key + +##### Parameters + +| Name | Located in | Description | Required | Schema | +| ---- | ---------- | ----------- | -------- | ---- | +| cert | body | cert of SSL | Yes | string | +| key | body | key of SSL | Yes | string | + +##### Responses + +| Code | Description | Schema | +| ---- | ----------- | ------ | +| 0 | SSL verify passed | [ApiError](#ApiError) | +| default | unexpected error | [ApiError](#ApiError) | + +### /apisix/admin/check_ssl_exists + +#### POST +##### Description: + +check SSL exists or not by sni + +##### Parameters + +| Name | Located in | Description | Required | Schema | +| ---- | ---------- | ----------- | -------- | ---- | +| cert | body | cert of SSL | Yes | string | +| key | body | key of SSL | Yes | string | + +##### Responses + +| Code | Description | Schema | +| ---- | ----------- | ------ | +| 0 | SSL exists | [ApiError](#ApiError) | +| default | unexpected error | [ApiError](#ApiError) | + +### /apisix/admin/consumers + +#### GET +##### Description: + +Return the consumer list according to the specified page number and page size, and can search by username + +##### Parameters + +| Name | Located in | Description | Required | Schema | +| ---- | ---------- | ----------- | -------- | ---- | +| page | query | page number | No | integer | +| page_size | query | page size | No | integer | +| username | query | username of consumer | No | string | + +##### Responses + +| Code | Description | Schema | +| ---- | ----------- | ------ | +| 0 | list response | [ [consumer](#consumer) ] | +| default | unexpected error | [ApiError](#ApiError) | + +### /apisix/admin/notexist/routes + +#### GET +##### Description: + +Returns result of route exists checking by name and exclude id + +##### Parameters + +| Name | Located in | Description | Required | Schema | +| ---- | ---------- | ----------- | -------- | ---- | +| name | query | name of route | No | string | +| exclude | query | id of route that exclude checking | No | string | + +##### Responses + +| Code | Description | Schema | +| ---- | ----------- | ------ | +| 0 | route not exists | [ApiError](#ApiError) | +| default | unexpected error | [ApiError](#ApiError) | + +### /apisix/admin/routes + +#### GET +##### Description: + +Return the route list according to the specified page number and page size, and can search by name and uri + +##### Parameters + +| Name | Located in | Description | Required | Schema | +| ---- | ---------- | ----------- | -------- | ---- | +| page | query | page number | No | integer | +| page_size | query | page size | No | integer | +| name | query | name of route | No | string | +| uri | query | uri of route | No | string | + +##### Responses + +| Code | Description | Schema | +| ---- | ----------- | ------ | +| 0 | list response | [ [route](#route) ] | +| default | unexpected error | [ApiError](#ApiError) | + +### /apisix/admin/services + +#### GET +##### Description: + +Return the service list according to the specified page number and page size, and can search by name + +##### Parameters + +| Name | Located in | Description | Required | Schema | +| ---- | ---------- | ----------- | -------- | ---- | +| page | query | page number | No | integer | +| page_size | query | page size | No | integer | +| name | query | name of service | No | string | + +##### Responses + +| Code | Description | Schema | +| ---- | ----------- | ------ | +| 0 | list response | [ [service](#service) ] | +| default | unexpected error | [ApiError](#ApiError) | + +### /apisix/admin/ssl + +#### GET +##### Description: + +Return the SSL list according to the specified page number and page size, and can search by sni + +##### Parameters + +| Name | Located in | Description | Required | Schema | +| ---- | ---------- | ----------- | -------- | ---- | +| page | query | page number | No | integer | +| page_size | query | page size | No | integer | +| sni | query | sni of SSL | No | string | + +##### Responses + +| Code | Description | Schema | +| ---- | ----------- | ------ | +| 0 | list response | [ [ssl](#ssl) ] | +| default | unexpected error | [ApiError](#ApiError) | + +### /apisix/admin/upstreams + +#### GET +##### Description: + +Return the upstream list according to the specified page number and page size, and can search by name + +##### Parameters + +| Name | Located in | Description | Required | Schema | +| ---- | ---------- | ----------- | -------- | ---- | +| page | query | page number | No | integer | +| page_size | query | page size | No | integer | +| name | query | name of upstream | No | string | + +##### Responses + +| Code | Description | Schema | +| ---- | ----------- | ------ | +| 0 | list response | [ [upstream](#upstream) ] | +| default | unexpected error | [ApiError](#ApiError) | + +### /apisix/admin/user/login + +#### POST +##### Description: + +user login + +##### Parameters + +| Name | Located in | Description | Required | Schema | +| ---- | ---------- | ----------- | -------- | ---- | +| username | body | user name | Yes | string | +| password | body | password | Yes | string | + +##### Responses + +| Code | Description | Schema | +| ---- | ----------- | ------ | +| 0 | login success | [ApiError](#ApiError) | +| default | unexpected error | [ApiError](#ApiError) | + +### Models + + +#### ApiError + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| code | long | response code | No | +| message | string | response message | No | + +#### BaseInfo + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| create_time | long | | No | +| id | object | | No | +| update_time | long | | No | + +#### Consumer + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| create_time | long | | No | +| desc | string | | No | +| id | object | | No | +| labels | object | | No | +| plugins | object | | No | +| update_time | long | | No | +| username | string | | No | + +#### LoginInput + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| password | string | password | No | +| username | string | user name | No | + +#### Route Review comment: I think we can do this later. and we can add `SSL`, `Service`, `Upstream` later too ########## File path: docs/api/api.md ########## @@ -0,0 +1,359 @@ +<!-- +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +--> + +# API doc of Manager API. +Manager API directly operates ETCD and provides data management for APISIX, provides APIs for Front-end or other clients. + +**License:** [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0) + +### /apisix/admin/check_ssl_cert + +#### POST +##### Description: + +verify SSL cert and key + +##### Parameters + +| Name | Located in | Description | Required | Schema | +| ---- | ---------- | ----------- | -------- | ---- | +| cert | body | cert of SSL | Yes | string | +| key | body | key of SSL | Yes | string | + +##### Responses + +| Code | Description | Schema | +| ---- | ----------- | ------ | +| 0 | SSL verify passed | [ApiError](#ApiError) | +| default | unexpected error | [ApiError](#ApiError) | + +### /apisix/admin/check_ssl_exists + +#### POST +##### Description: + +check SSL exists or not by sni Review comment: `check SSL exists or not by sni`, not easy to understand ########## File path: docs/FAQ.md ########## @@ -54,3 +54,21 @@ $ api/build-tools/schema-sync.sh /usr/local/apisix ``` After the command finishes executing, if you are using a binary `manager-api` that has already been built, you will need to manually copy `api/conf/schema.json` to the `conf` directory under the Dashboard **working directory**. where **working directory** refers to the `conf` directory under this [document](./deploy.md) is the `output` directory, or the directory with the modified name, that is generated in the root directory after the build is complete. + +### 5. How to write api interface documentation + +We use [go-swagger](https://github.com/go-swagger/go-swagger) to generate Swagger 2.0 documents, and then convert them to markdown format so that they can be viewed directly in the github repository. Specific steps are as follows: + +1. Write comments according to [Specification](https://goswagger.io/use/spec.html). For details, please refer to the existing example `api/internal/handler/route/route.go` in this project. + +2. Use the `go-swagger` tool to generate Swagger 2.0 documents. + +```shell +$ swagger generate spec -o ./docs/api/api.yaml --scan-models +``` + +3. Use the `swagger-markdown` tool to convert Swagger 2.0 documents into markdown documents. + +```shell +$ swagger-markdown -i ./docs/api/api.yaml Review comment: ditto ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
