Skip to content
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

feat: support specifying APISIX path to generate json schema #765

Merged
merged 10 commits into from
Nov 10, 2020
Merged
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
1 change: 0 additions & 1 deletion .github/workflows/deploy-with-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,3 @@ jobs:
run: |
docker tag dashboard:ci apisixacr.azurecr.cn/dashboard:${{ github.sha }}
docker push apisixacr.azurecr.cn/dashboard:${{ github.sha }}

5 changes: 4 additions & 1 deletion api/build-tools/schema-sync.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ local fake_module_list = {
'pb',
'prometheus',
'protoc',
'skywalking.tracer',

'resty.cookie',
'resty.core.regex',
Expand Down Expand Up @@ -61,7 +62,8 @@ local fake_module_list = {
'apisix.plugins.skywalking.tracer',
'apisix.plugins.zipkin.codec',
'apisix.plugins.zipkin.random_sampler',
'apisix.plugins.zipkin.reporter'
'apisix.plugins.zipkin.reporter',
'apisix.timers'
}
for _, name in ipairs(fake_module_list) do
package.loaded[name] = {}
Expand All @@ -77,6 +79,7 @@ ngx.re = {}
ngx.timer = {}
ngx.location = {}
ngx.socket = {}
ngx.thread = {}
ngx.re.gmatch = empty_function
ngx.shared = {
["plugin-api-breaker"] = {}
Expand Down
30 changes: 20 additions & 10 deletions api/build-tools/schema-sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,29 @@ set -ex

pwd=`pwd`

version="master"
if [[ -n $1 ]]; then
version=$1
if [[ -n $1 && -d "$1" ]]; then
path=$1
if [[ -d "${path}/apisix" ]]; then
cp -R ${path}/apisix/ ./api/build-tools/apisix/
else
cp -R ${path}/ ./api/build-tools/apisix/
fi
else
version="master"
if [[ -n $1 ]]; then
version=$1
fi
wget -O $version.zip https://github.com/apache/apisix/archive/$version.zip

unzip $version.zip
mkdir -p ./api/build-tools/apisix/
cp -R ./apisix-$version/apisix/ ./api/build-tools/
rm -rf ./apisix-$version
fi

rm -rf ./api/build-tools/apisix/
wget -O $version.zip https://github.com/apache/apisix/archive/$version.zip
cd ./api/build-tools/ && lua schema-sync.lua > ${pwd}/api/conf/schema.json && cd ../../

unzip $version.zip
mkdir -p ./api/build-tools/apisix/
mv ./apisix-$version/apisix/* ./api/build-tools/apisix/
rm -rf ./apisix-$version
cd ./api/build-tools/ && lua schema-sync.lua > ${pwd}/api/conf/schema.json
rm -rf ./api/build-tools/apisix/

echo "sync success:"
echo "${pwd}/api/conf/schema.json"
12 changes: 11 additions & 1 deletion docs/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ $ make api-stop

### Sync jsonschema

To sync jsonschema from Apache APISIX, `Lua` 5.1+ and `zip` need to be preinstalled, then execute this command: `api/build-tools/schema-sync.sh $version`.
To sync jsonschema from Apache APISIX, `Lua` 5.1+ and `zip` need to be preinstalled, then execute this command:

```sh
$ api/build-tools/schema-sync.sh $version
```

NOTE: `$version` should be `master` or Apache APISIX's version.

Expand All @@ -100,3 +104,9 @@ $ api/build-tools/schema-sync.sh master
# Using Apache APISIX's version
$ api/build-tools/schema-sync.sh 2.0
```

If you have custom plugin, please make sure your custom plugin is placed in the APISIX directory, and change the parameters of the execution script to the APISIX directory path, example:

```sh
$ api/build-tools/schema-sync.sh /usr/local/apisix
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is not a good example, I think /your/path/apisix is better.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha this doc is outdated, we have another in reviewing PR.

```
11 changes: 10 additions & 1 deletion docs/develop.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@ $ make api-stop

### 同步 jsonschema

从 Apache APISIX 同步 jsonschema ,需要预安装 `Lua` 5.1+ 和 `zip` ,并执行命令 `api/build-tools/schema-sync.sh $version`。
从 Apache APISIX 同步 jsonschema ,需要预安装 `Lua` 5.1+ 和 `zip` ,并执行命令

```sh
$ api/build-tools/schema-sync.sh $version
```

注意:`$version` 为 `master` 或者 Apache APISIX 的版本号。

Expand All @@ -103,3 +107,8 @@ $ api/build-tools/schema-sync.sh master
$ api/build-tools/schema-sync.sh 2.0
```

如果您有自定义插件,请确保您的自定义插件放在 APISIX 目录中,并将执行脚本的参数改为 APISIX 目录路径, 如:

```sh
$ api/build-tools/schema-sync.sh /usr/local/apisix
```