diff --git a/openapi/python-asyncio.sh b/openapi/python-asyncio.sh index 7b098a9..9a35228 100755 --- a/openapi/python-asyncio.sh +++ b/openapi/python-asyncio.sh @@ -62,6 +62,13 @@ find "${OUTPUT_DIR}/client" -type f -name \*.py ! -name '__init__.py' -exec sed # + support application/strategic-merge-patch+json patch "${OUTPUT_DIR}/client/rest.py" "${SCRIPT_ROOT}/python-asyncio-rest.py.patch" +# workaround https://github.com/swagger-api/swagger-codegen/pull/8401 +find "${OUTPUT_DIR}/client/" -type f -name \*.py -exec sed -i 's/async=/async_req=/g' {} + +find "${OUTPUT_DIR}/client/" -type f -name \*.py -exec sed -i 's/async bool/async_req bool/g' {} + +find "${OUTPUT_DIR}/client/" -type f -name \*.py -exec sed -i "s/'async'/'async_req'/g" {} + +find "${OUTPUT_DIR}/client/" -type f -name \*.py -exec sed -i "s/async parameter/async_req parameter/g" {} + +find "${OUTPUT_DIR}/client/" -type f -name \*.py -exec sed -i "s/if not async/if not async_req/g" {} + + # fix imports find "${OUTPUT_DIR}/client/" -type f -name \*.py -exec sed -i 's/import client\./import kubernetes_asyncio.client./g' {} + find "${OUTPUT_DIR}/client/" -type f -name \*.py -exec sed -i 's/from client/from kubernetes_asyncio.client/g' {} + diff --git a/openapi/python.sh b/openapi/python.sh index 5c96aac..0e3386a 100644 --- a/openapi/python.sh +++ b/openapi/python.sh @@ -52,6 +52,14 @@ CLEANUP_DIRS=(client/apis client/models docs test); \ kubeclient::generator::generate_client "${OUTPUT_DIR}" echo "--- Patching generated code..." + +# workaround https://github.com/swagger-api/swagger-codegen/pull/8401 +find "${OUTPUT_DIR}/client/" -type f -name \*.py -exec sed -i 's/async=/async_req=/g' {} + +find "${OUTPUT_DIR}/client/" -type f -name \*.py -exec sed -i 's/async bool/async_req bool/g' {} + +find "${OUTPUT_DIR}/client/" -type f -name \*.py -exec sed -i "s/'async'/'async_req'/g" {} + +sed -i "s/if not async/if not async_req/g" "${OUTPUT_DIR}/client/api_client.py" +# + find "${OUTPUT_DIR}/test" -type f -name \*.py -exec sed -i 's/\bclient/kubernetes.client/g' {} + find "${OUTPUT_DIR}" -path "${OUTPUT_DIR}/base" -prune -o -type f -a -name \*.md -exec sed -i 's/\bclient/kubernetes.client/g' {} + find "${OUTPUT_DIR}" -path "${OUTPUT_DIR}/base" -prune -o -type f -a -name \*.md -exec sed -i 's/kubernetes.client-python/client-python/g' {} +