Skip to content

Commit

Permalink
update generator with new endpoints
Browse files Browse the repository at this point in the history
Signed-off-by: Michele Dolfi <[email protected]>
  • Loading branch information
dolfim-ibm committed Mar 13, 2024
1 parent dbdfc99 commit 7f4236b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
14 changes: 14 additions & 0 deletions tools/swagger-client-generator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,17 @@ If you don't want to download the Swagger Specification, and just want to use th
```bash
./tools/swagger-client-generator/generate-client.sh .
```

## Podman setup

For mounting the user folder in Podman, make sure the machine was created with the option `-v $HOME:$HOME`.

To re-initialize your default podman machine, you can run the following commands

```sh
podman machine stop podman-machine-default
podman machine rm podman-machine-default

podman machine init -v $HOME:$HOME
podman machine start
```
19 changes: 18 additions & 1 deletion tools/swagger-client-generator/generate-client.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ rootdir=$curdir/../../
base_path=${1:?"Please specify a base path. For example https://your-host/api/cps"}

generator_image="openapitools/openapi-generator-cli:v4.3.1"
generator_image_v2="openapitools/openapi-generator-cli:v7.4.0"

# generator_image="openapitools/openapi-generator-cli:v4.2.3"
# generator_image="openapitools/openapi-generator-cli:v5.2.1"

function download_swagger {
Expand All @@ -23,6 +23,7 @@ function download_swagger {

if [[ "${base_path}" == http* ]]; then
download_swagger "${base_path}/public/v1/swagger.json" "${curdir}/swagger-cps.json"
download_swagger "${base_path}/public/v2/openapi.json" "${curdir}/openapi-ds-v2.json"
download_swagger "${base_path}/user/v1/swagger.json" "${curdir}/swagger-user.json"
download_swagger "${base_path}/kg/v1/swagger.json" "${curdir}/swagger-cps-kg.json"
fi
Expand Down Expand Up @@ -53,6 +54,17 @@ podman run --rm \
-o /local/.generated/cps-user \
-c /local/tools/swagger-client-generator/openapi-generator-config-user.json

echo "Generating client for DS API v2"

podman run --rm \
-v "$(pwd):/local" \
--userns=keep-id:uid="$(id -u)",gid="$(id -g)" \
${generator_image_v2} generate \
-i "/local/tools/swagger-client-generator/openapi-ds-v2.json" \
-g python \
-o /local/.generated/ds-public-v2 \
-c /local/tools/swagger-client-generator/openapi-generator-config-ds-v2.json

# echo "Generating client for the CPS KG API"
# echo "Currently disabled: TODO FIX API Specs"

Expand Down Expand Up @@ -101,13 +113,15 @@ echo "Merging packages..."
# Remove generated API client code
rm -rf $rootdir/deepsearch/cps/apis/public || true
rm -rf $rootdir/deepsearch/cps/apis/user || true
rm -rf $rootdir/deepsearch/cps/apis/public_v2 || true
# rm -rf $rootdir/deepsearch/cps/apis/kg || true

mkdir -p $rootdir/deepsearch/cps/apis
touch $rootdir/deepsearch/cps/apis/__init__.py

cp -R .generated/cps-public/deepsearch/cps/apis/ $rootdir/deepsearch/cps/apis/
cp -R .generated/cps-user/deepsearch/cps/apis/ $rootdir/deepsearch/cps/apis/
cp -R .generated/ds-public-v2/deepsearch/cps/apis/ $rootdir/deepsearch/cps/apis/
# cp -R .generated/cps-kg-create/deepsearch/cps/apis/ $rootdir/deepsearch/cps/apis/
# cp -R .generated/cps-kg-query/deepsearch/cps/apis/ $rootdir/deepsearch/cps/apis/

Expand All @@ -117,14 +131,17 @@ echo "Copying documentation files..."
rm -rf $rootdir/docs/apis/kg || true
rm -rf $rootdir/docs/apis/public || true
rm -rf $rootdir/docs/apis/user || true
rm -rf $rootdir/docs/apis/public_v2 || true

mkdir -p $rootdir/docs/apis/public
mkdir -p $rootdir/docs/apis/public_v2
mkdir -p $rootdir/docs/apis/user
mkdir -p $rootdir/docs/apis/kg/query
mkdir -p $rootdir/docs/apis/kg/create

cp -R .generated/cps-public/docs/* $rootdir/docs/apis/public
cp -R .generated/cps-user/docs/* $rootdir/docs/apis/user
cp -R .generated/ds-public-v2/docs/* $rootdir/docs/apis/public_v2
# cp -R .generated/cps-kg-query/docs/* $rootdir/docs/apis/kg/create
# cp -R .generated/cps-kg-create/docs/* $rootdir/docs/apis/kg/query

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"packageName": "deepsearch.cps.apis.public_v2",
"projectName": "ds-public",
"packageVersion": "2.0.0"
}

0 comments on commit 7f4236b

Please sign in to comment.