diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml new file mode 100644 index 0000000..08d824b --- /dev/null +++ b/.github/workflows/checks.yml @@ -0,0 +1,13 @@ +name: Run Checks + +on: + push + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: openapi-generators/openapi-python-client-action@v2 + with: + openapi-url: https://raw.githubusercontent.com/openapi-generators/openapi-python-client/main/end_to_end_tests/openapi.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f11b75 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ diff --git a/Dockerfile b/Dockerfile index 8b47312..e22f801 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,9 @@ -FROM python:3.9 +FROM python:3.9-slim RUN python -m pip install --upgrade pip -RUN pip install pipx # Sets the user to the same user that the workflow runner uses so that it can access the generated client -USER 1001 +USER 1001 COPY entrypoint.sh /entrypoint.sh diff --git a/README.md b/README.md index 8c0365c..447d01e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # openapi-python-client-action -The official GitHub Action for [openapi-python-client](https://github.com/triaxtec/openapi-python-client) - generates a modern Python client package from an OpenAPI document +The official GitHub Action for [openapi-python-client](https://github.com/openapi-generators/openapi-python-client) - generates a modern Python client package from an OpenAPI document ## Inputs @@ -17,7 +17,11 @@ The url of the OpenAPI document. Overrides `openapi-file` - If unspecified the v ### `config-file` -The path (with respect to the current directory/the workspace) to the config.yml to be used with openapi-python-client. Configuaration is not required so if this is unspecified then no configuration will be passed along. See [openapi-python-client's README](https://github.com/triaxtec/openapi-python-client#configuration) for available configuration +The path (with respect to the current directory/the workspace) to the config.yml to be used with openapi-python-client. Configuaration is not required so if this is unspecified then no configuration will be passed along. See [openapi-python-client's README](https://github.com/openapi-generators/openapi-python-client#configuration) for available configuration + +### `extra-args` + +This is a catch-all to allow you to pass additional arguments to `openapi-python-client`. ## Outputs @@ -41,7 +45,7 @@ jobs: # Use the action to generate a client package # This uses all defaults (latest version, openapi.json in the current workspace, no configuration) - name: Generate Python Client - uses: triaxtec/openapi-python-client-action@v2 + uses: openapi-generators/openapi-python-client-action@v2 # Do something with the generated client (likely publishing it somewhere) # Here we assume that the info/title in the openapi document was "example-project" diff --git a/action.yml b/action.yml index 8762f3a..0ce9d43 100644 --- a/action.yml +++ b/action.yml @@ -21,6 +21,10 @@ inputs: description: Path to the config file to be passed along to openapi-python-client required: false default: NOT_SPECIFIED + extra-args: + description: Any additional arguments to forward to openapi-python-client + required: false + default: "" runs: using: "docker" @@ -30,3 +34,4 @@ runs: - ${{ inputs.openapi-file }} - ${{ inputs.openapi-url }} - ${{ inputs.config-file }} + - ${{ inputs.extra-args }} diff --git a/entrypoint.sh b/entrypoint.sh index 226dbf5..3a74825 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,25 +1,31 @@ #!/bin/bash +set -euo pipefail +IFS=$'\n\t' openapi_python_client_version=$1 openapi_file_path=$2 openapi_url=$3 config_file_path=$4 +extra_args=$5 if [[ "$openapi_python_client_version" != "NOT_SPECIFIED" ]]; then - version_arg="--spec openapi-python-client==${openapi_python_client_version}" + version_arg="openapi-python-client==${openapi_python_client_version}" else - version_arg="" + version_arg="openapi-python-client" fi if [[ "$config_file_path" != "NOT_SPECIFIED" ]]; then - config_arg="--config ${config_file_path}" + config_arg="--config=${config_file_path}" else config_arg="" fi -openapi_document_path_or_url_arg="--path ${openapi_file_path}" +openapi_document_path_or_url_arg="--path=${openapi_file_path}" if [[ "$openapi_url" != "NOT_SPECIFIED" ]]; then - openapi_document_path_or_url_arg="--url ${openapi_url}" + openapi_document_path_or_url_arg="--url=${openapi_url}" fi -pipx run ${version_arg} openapi-python-client generate ${config_arg} ${openapi_document_path_or_url_arg} +PATH=$PATH:/github/home/.local/bin +pip install "${version_arg}" +# shellcheck disable=SC2086 +openapi-python-client generate $config_arg $openapi_document_path_or_url_arg $extra_args