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

Rework fixing api spec #100

Merged
merged 1 commit into from
Jul 8, 2024
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
8 changes: 1 addition & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
# WARNING: DO NOT EDIT!
#
# This file was generated by plugin_template, and is managed by it. Please use
# './plugin-template --github pulp_file' to update this file.
#
# For more info visit https://github.com/pulp/plugin_template
---
name: pulp-openapi-generator PR CI
on: pull_request
Expand Down Expand Up @@ -66,7 +60,7 @@ jobs:
run: |
echo ::group::HTTPIE
sudo apt-get update -yq
sudo -E apt-get -yq --no-install-suggests --no-install-recommends install httpie
sudo -E apt-get -yq --no-install-suggests --no-install-recommends install httpie jq
echo ::endgroup::
echo "HTTPIE_CONFIG_DIR=$GITHUB_WORKSPACE/.ci/assets/httpie/" >> $GITHUB_ENV

Expand Down
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ target/
#Ipython Notebook
.ipynb_checkpoints

# written in generate.sh
.openapi-generator-ignore

# generated client packages
# generated stuff
/api.json
/patched-api.json
/*-client/
.openapi-generator-ignore
19 changes: 15 additions & 4 deletions gen-client.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,23 @@ else
VOLUME_DIR="${PWD}"
fi

REMOVE_COOKIE_AUTH_FILTER='del(.paths[][].security|select(.)[]|select(.cookieAuth))|del(.components.securitySchemes.cookieAuth)'

# These two may be needed when upgrading the generator image
FIX_TASK_CREATED_RESOURCES_FILTER='(.components.schemas.TaskResponse|select(.)|.properties.created_resources.items) |= {"$oneOf":[{type:"null"},.]}'
FIX_TASK_ERROR_FILTER='(.components.schemas.TaskResponse|select(.)|.properties.error) |= (del(.readOnly) | .additionalProperties.type = "string")'

if [ "$LANGUAGE" = "python" ]
then
cat "${API_SPEC}" | jq "." > patched-api.json

$CONTAINER_EXEC run \
"${ULIMIT_COMMAND[@]}" \
"${USER_COMMAND[@]}" \
--rm \
"${VOLUME_OPTION[@]}" \
"$OPENAPI_PYTHON_IMAGE" generate \
-i "${VOLUME_DIR}/${API_SPEC}" \
-i "${VOLUME_DIR}/patched-api.json" \
-g python \
-o "${VOLUME_DIR}/${PACKAGE}-client" \
"--additional-properties=packageName=pulpcore.client.${PACKAGE},projectName=${PACKAGE}-client,packageVersion=${VERSION},domainEnabled=${DOMAIN_ENABLED}" \
Expand All @@ -86,14 +94,15 @@ then
mkdir -p "${PACKAGE}-client"
echo git_push.sh > "${PACKAGE}-client/.openapi-generator-ignore"

python3 remove-cookie-auth.py
cat "${API_SPEC}" | jq "${REMOVE_COOKIE_AUTH_FILTER}" > patched-api.json

$CONTAINER_EXEC run \
"${ULIMIT_COMMAND[@]}" \
"${USER_COMMAND[@]}" \
--rm \
"${VOLUME_OPTION[@]}" \
"$OPENAPI_RUBY_IMAGE" generate \
-i "${VOLUME_DIR}/${API_SPEC}" \
-i "${VOLUME_DIR}/patched-api.json" \
-g ruby \
-o "${VOLUME_DIR}/${PACKAGE}-client" \
"--additional-properties=gemName=${PACKAGE}_client,gemLicense="GPLv2+",gemVersion=${VERSION},gemHomepage=https://github.com/pulp/${PACKAGE}" \
Expand All @@ -105,13 +114,15 @@ fi

if [ "$LANGUAGE" = "typescript" ]
then
cat "${API_SPEC}" | jq "." > patched-api.json

$CONTAINER_EXEC run \
"${ULIMIT_COMMAND[@]}" \
"${USER_COMMAND[@]}" \
--rm \
"${VOLUME_OPTION[@]}" \
"$OPENAPI_TYPESCRIPT_IMAGE" generate \
-i "${VOLUME_DIR}/${API_SPEC}" \
-i "${VOLUME_DIR}/patched-api.json" \
-g typescript-axios \
-o "${VOLUME_DIR}/${PACKAGE}-client" \
-t "${VOLUME_DIR}/templates/typescript-axios" \
Expand Down
58 changes: 0 additions & 58 deletions remove-cookie-auth.py

This file was deleted.

Loading