-
Notifications
You must be signed in to change notification settings - Fork 147
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: switch python client to use openapi-generator #97
Merged
k8s-ci-robot
merged 2 commits into
kubernetes-client:master
from
tomplus:feat/python-openapi-generator
Sep 13, 2019
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,29 +43,23 @@ pushd "${OUTPUT_DIR}" > /dev/null | |
OUTPUT_DIR=`pwd` | ||
popd > /dev/null | ||
|
||
source "${SCRIPT_ROOT}/swagger-codegen/client-generator.sh" | ||
source "${SCRIPT_ROOT}/openapi-generator/client-generator.sh" | ||
source "${SETTING_FILE}" | ||
|
||
SWAGGER_CODEGEN_COMMIT="${SWAGGER_CODEGEN_COMMIT:-d2b91073e1fc499fea67141ff4c17740d25f8e83}"; \ | ||
CLIENT_LANGUAGE=python; \ | ||
CLEANUP_DIRS=(client/apis client/models docs test); \ | ||
CLEANUP_DIRS=(client/api 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 | ||
# TODO: Remove this when above merges | ||
find "${OUTPUT_DIR}/${PACKAGE_NAME}/" -type f -name \*.py -exec sed -i 's/async=/async_req=/g' {} + | ||
find "${OUTPUT_DIR}/${PACKAGE_NAME}/" -type f -name \*.py -exec sed -i 's/async bool/async_req bool/g' {} + | ||
find "${OUTPUT_DIR}/${PACKAGE_NAME}/" -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}/${PACKAGE_NAME}/api_client.py" | ||
# | ||
|
||
# workaround https://github.com/swagger-api/swagger-codegen/pull/8061 (thread pool only on demand) | ||
# TODO: Remove this when above merges | ||
patch "${OUTPUT_DIR}/${PACKAGE_NAME}/api_client.py" "${SCRIPT_ROOT}/python-api_client.py.patch" --no-backup-if-mismatch | ||
|
||
# Post-processing of the generated Python wrapper. | ||
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' {} + | ||
|
||
# fix imports | ||
find "${OUTPUT_DIR}/client/" -type f -name \*.py -exec sed -i 's/import client\./import kubernetes.client./g' {} + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Absolute vs relative imports. It's not related to the openapi-generator too, the latest version of swagger-codegen uses absolute imports and here it's fixed by adding prefix |
||
find "${OUTPUT_DIR}/client/" -type f -name \*.py -exec sed -i 's/from client/from kubernetes.client/g' {} + | ||
find "${OUTPUT_DIR}/client/" -type f -name \*.py -exec sed -i 's/getattr(client\.models/getattr(kubernetes.client.models/g' {} + | ||
|
||
echo "---Done." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sub-package is renamed from
apis
toapi
. This changes has been already introduced in swagger-codegen.