feat: switch all variants of the generated library to use openapi-generator (#136)

This commit is contained in:
Tomasz Prus
2019-11-19 19:59:20 +01:00
committed by Kubernetes Prow Robot
parent 270d42bbe8
commit 1203c13a32

View File

@@ -43,18 +43,18 @@ popd > /dev/null
source "${SETTING_FILE}"
# use openapi-generator to generate library
source "${SCRIPT_ROOT}/openapi-generator/client-generator.sh"
CLIENT_LANGUAGE=python-asyncio
CLEANUP_DIRS=(client/apis client/models docs test)
kubeclient::generator::generate_client "${OUTPUT_DIR}"
# Generic patches to the generated Python code, most notably renaming the library.
echo "--- Patching generated code..."
if [ ${PACKAGE_NAME} == "client" ]; then
# use openapi-generator to generate library
source "${SCRIPT_ROOT}/openapi-generator/client-generator.sh"
CLIENT_LANGUAGE=python-asyncio
CLEANUP_DIRS=(client/apis client/models docs test)
kubeclient::generator::generate_client "${OUTPUT_DIR}"
# Generic patches to the generated Python code, most notably renaming the library.
echo "--- Patching generated code..."
# Post-processing of the generated Python wrapper.
find "${OUTPUT_DIR}/test" -type f -name \*.py -exec sed -i 's/\bclient/kubernetes_asyncio.client/g' {} +
find "${OUTPUT_DIR}" -path "${OUTPUT_DIR}/base" -prune -o -type f -a -name \*.md -exec sed -i 's/\bclient/kubernetes_asyncio.client/g' {} +
@@ -67,26 +67,11 @@ if [ ${PACKAGE_NAME} == "client" ]; then
else
# use swagger-codegen to generate library
source "${SCRIPT_ROOT}/swagger-codegen/client-generator.sh"
SWAGGER_CODEGEN_COMMIT=v2.3.1
# Build the client library in a Docker container.
CLIENT_LANGUAGE=python-asyncio
CLEANUP_DIRS=(client/apis client/models docs test)
kubeclient::generator::generate_client "${OUTPUT_DIR}"
# Generic patches to the generated Python code, most notably renaming the library.
echo "--- Patching generated code..."
# Post-processing of the generated Python wrapper.
find "${OUTPUT_DIR}/test" -type f -name \*.py -exec sed -i "s/\\bclient/${PACKAGE_NAME}.client/g" {} +
find "${OUTPUT_DIR}" -path "${OUTPUT_DIR}/base" -prune -o -type f -a -name \*.md -exec sed -i "s/\\bclient/${PACKAGE_NAME}.client/g" {} +
find "${OUTPUT_DIR}" -path "${OUTPUT_DIR}/base" -prune -o -type f -a -name \*.md -exec sed -i "s/${PACKAGE_NAME}.client-python/client-python/g" {} +
# Remove circular imports in `v1beta1_json_schema_props.py`.
sed -i "/^from ${PACKAGE_NAME}\.models.*/d" "${PACKAGE_NAME}/${PACKAGE_NAME}/models/v1beta1_json_schema_props.py"
fi
echo "---Done."