From c603ce7051c44d9ef2e09c7fcb60a55d9cc245e5 Mon Sep 17 00:00:00 2001 From: Ethan Mann Date: Thu, 14 Jan 2021 12:13:20 -0500 Subject: [PATCH 01/23] Initial draft/some testing --- action.yml | 24 ++++++++++++++++++++++++ dockerfile | 5 +++++ entrypoint.sh | 1 + 3 files changed, 30 insertions(+) create mode 100644 action.yml create mode 100644 dockerfile create mode 100644 entrypoint.sh diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..c3b0861 --- /dev/null +++ b/action.yml @@ -0,0 +1,24 @@ +name: "Generate python client package for openapi spec" +description: "" +branding: + icon: "target" + color: "green" + +inputs: + openapi-python-client-version: + description: "The version of openapi-python-client to use when generating the client package" + required: true + openapi-file: + description: "Path to the openapi spec file (json or yml) to generate a client for" + required: true + output-path: + description: "Path to the parent directory to place the generated client within." + required: false + default: "." + config-file: + description: "Path to the config file to be passed along to openapi-python-client" + required: false + +runs: + using: "docker" + image: "DockerFile" \ No newline at end of file diff --git a/dockerfile b/dockerfile new file mode 100644 index 0000000..f660768 --- /dev/null +++ b/dockerfile @@ -0,0 +1,5 @@ +FROM python:3.8 + +RUN python -m pip install pipx + +ENTRYPOINT: ["entrypoint.sh"] \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..f373150 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1 @@ +ls /github/home \ No newline at end of file From 9a7ba023b02c078a83bffc14c13808243c40ec66 Mon Sep 17 00:00:00 2001 From: Ethan Mann Date: Thu, 14 Jan 2021 13:00:35 -0500 Subject: [PATCH 02/23] fixing the dockerfile name --- dockerfile | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 dockerfile diff --git a/dockerfile b/dockerfile deleted file mode 100644 index f660768..0000000 --- a/dockerfile +++ /dev/null @@ -1,5 +0,0 @@ -FROM python:3.8 - -RUN python -m pip install pipx - -ENTRYPOINT: ["entrypoint.sh"] \ No newline at end of file From 2cdf4df6987c648ec0312d0e874134945f99b5d1 Mon Sep 17 00:00:00 2001 From: Ethan Mann Date: Thu, 14 Jan 2021 13:00:53 -0500 Subject: [PATCH 03/23] Fixed Dockerfile name --- Dockerfile | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f660768 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,5 @@ +FROM python:3.8 + +RUN python -m pip install pipx + +ENTRYPOINT: ["entrypoint.sh"] \ No newline at end of file From 36dd51137ad028d1e79b96a5f92ffe9f903451d4 Mon Sep 17 00:00:00 2001 From: Ethan Mann Date: Thu, 14 Jan 2021 13:02:15 -0500 Subject: [PATCH 04/23] Fixed typo --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index c3b0861..fa49f14 100644 --- a/action.yml +++ b/action.yml @@ -21,4 +21,4 @@ inputs: runs: using: "docker" - image: "DockerFile" \ No newline at end of file + image: "Dockerfile" \ No newline at end of file From 4083a57a09b1b9a80bdd932e6b52b6623078b201 Mon Sep 17 00:00:00 2001 From: Ethan Mann Date: Thu, 14 Jan 2021 13:06:41 -0500 Subject: [PATCH 05/23] Fixed typo in dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index f660768..c48b544 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,4 +2,4 @@ FROM python:3.8 RUN python -m pip install pipx -ENTRYPOINT: ["entrypoint.sh"] \ No newline at end of file +ENTRYPOINT ["entrypoint.sh"] \ No newline at end of file From f439b68b00301ef73ccfbdc3aec92d08f198c882 Mon Sep 17 00:00:00 2001 From: Ethan Mann Date: Thu, 14 Jan 2021 13:09:43 -0500 Subject: [PATCH 06/23] Copy entrypoint into image --- Dockerfile | 1 + entrypoint.sh | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c48b544..1802311 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,6 @@ FROM python:3.8 RUN python -m pip install pipx +COPY entrypoint.sh /entrypoint.sh ENTRYPOINT ["entrypoint.sh"] \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh index f373150..c86c55b 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1 +1,2 @@ -ls /github/home \ No newline at end of file +ls /github/home +ls /github/workflow \ No newline at end of file From 520970a72db38dc5873c4c7dd2c062814d74c8f7 Mon Sep 17 00:00:00 2001 From: Ethan Mann Date: Thu, 14 Jan 2021 13:11:42 -0500 Subject: [PATCH 07/23] Fix typo --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 1802311..329cf05 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,4 +3,4 @@ FROM python:3.8 RUN python -m pip install pipx COPY entrypoint.sh /entrypoint.sh -ENTRYPOINT ["entrypoint.sh"] \ No newline at end of file +ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file From 7a85cab83b65448ad439bb8a09cb229066e5a7f8 Mon Sep 17 00:00:00 2001 From: Ethan Mann Date: Thu, 14 Jan 2021 13:15:11 -0500 Subject: [PATCH 08/23] Made entrypoint executable --- entrypoint.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 entrypoint.sh diff --git a/entrypoint.sh b/entrypoint.sh old mode 100644 new mode 100755 From a05c9955446c280df39fdb5e92d71e30b7a4aba1 Mon Sep 17 00:00:00 2001 From: Ethan Mann Date: Thu, 14 Jan 2021 13:17:40 -0500 Subject: [PATCH 09/23] Added shebang to entrypoint --- entrypoint.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/entrypoint.sh b/entrypoint.sh index c86c55b..a474e1d 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,2 +1,4 @@ +#!/bin/sh -l + ls /github/home ls /github/workflow \ No newline at end of file From c53f056a345dce93c2a6b74d696fe66e7a43f8b9 Mon Sep 17 00:00:00 2001 From: Ethan Mann Date: Thu, 14 Jan 2021 13:33:41 -0500 Subject: [PATCH 10/23] Input is now actaully used --- action.yml | 4 +++- entrypoint.sh | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index fa49f14..7025187 100644 --- a/action.yml +++ b/action.yml @@ -21,4 +21,6 @@ inputs: runs: using: "docker" - image: "Dockerfile" \ No newline at end of file + image: "Dockerfile" + args: + - ${{ inputs.openapi-file }} \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh index a474e1d..7fe3089 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,4 +1,3 @@ #!/bin/sh -l -ls /github/home -ls /github/workflow \ No newline at end of file +python -m pipx run openapi-python-client generate --path $1 \ No newline at end of file From 77ba1bdae92d4d7f685f3744d83422c4c6756c0d Mon Sep 17 00:00:00 2001 From: Ethan Mann Date: Thu, 14 Jan 2021 14:01:37 -0500 Subject: [PATCH 11/23] Attempt to fix file permissions issues --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 329cf05..55a899f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,4 +3,6 @@ FROM python:3.8 RUN python -m pip install pipx COPY entrypoint.sh /entrypoint.sh +USER 1000:1000 + ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file From 8a0ebc5b6894948f750a9a2d689a3afa3aed5329 Mon Sep 17 00:00:00 2001 From: Ethan Mann Date: Thu, 14 Jan 2021 14:09:09 -0500 Subject: [PATCH 12/23] Attempt #2 to fix file permission issues --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 55a899f..9f1948a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,6 @@ FROM python:3.8 RUN python -m pip install pipx COPY entrypoint.sh /entrypoint.sh -USER 1000:1000 +USER root ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file From de030e2649564701e1700d387f4bf4ccb1bf4b39 Mon Sep 17 00:00:00 2001 From: Ethan Mann Date: Thu, 14 Jan 2021 14:29:03 -0500 Subject: [PATCH 13/23] Trying changing user back to 1001 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 9f1948a..2977f51 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,6 @@ FROM python:3.8 RUN python -m pip install pipx COPY entrypoint.sh /entrypoint.sh -USER root +USER 1001:10001 ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file From 5057a8bd25816d66e8308629036c188c872f651d Mon Sep 17 00:00:00 2001 From: Ethan Mann Date: Wed, 27 Jan 2021 11:06:30 -0500 Subject: [PATCH 14/23] Updated inputs and how they are handled --- Dockerfile | 3 --- action.yml | 15 ++++++++------- entrypoint.sh | 12 +++++++++++- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2977f51..9893fd1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,5 @@ FROM python:3.8 -RUN python -m pip install pipx COPY entrypoint.sh /entrypoint.sh -USER 1001:10001 - ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/action.yml b/action.yml index 7025187..b1d0ed8 100644 --- a/action.yml +++ b/action.yml @@ -7,20 +7,21 @@ branding: inputs: openapi-python-client-version: description: "The version of openapi-python-client to use when generating the client package" - required: true + required: false + default: "latest" openapi-file: - description: "Path to the openapi spec file (json or yml) to generate a client for" - required: true - output-path: - description: "Path to the parent directory to place the generated client within." + description: The path to the openapi document to generate a client library for required: false - default: "." + default: openapi.json config-file: description: "Path to the config file to be passed along to openapi-python-client" required: false + default: NOT_SPECIFIED runs: using: "docker" image: "Dockerfile" args: - - ${{ inputs.openapi-file }} \ No newline at end of file + - ${{ inputs.openapi-python-client-version }} + - ${{ inputs.openapi-file }} + - ${{ inputs.config-file }} \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh index 7fe3089..1c34312 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,3 +1,13 @@ #!/bin/sh -l -python -m pipx run openapi-python-client generate --path $1 \ No newline at end of file +openapi_python_client_version = $1 +openapi_file_path = $2 +config_file_path = $3 + +pip install openapi-python-client==${openapi_python_client_version} + +if [[ "$config_file_path" == "NOT_SPECIFIED" ]]; then + python -m openapi-python-client generate --path ${openapi_file_path} +else + python -m openapi-python-client generate --path ${openapi_file_path} --config ${config_file_path} +fi \ No newline at end of file From 83d187d0cb6d1b76febbbe543e80cbe700a1e940 Mon Sep 17 00:00:00 2001 From: Ethan Mann Date: Wed, 27 Jan 2021 11:14:22 -0500 Subject: [PATCH 15/23] Debugging --- entrypoint.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/entrypoint.sh b/entrypoint.sh index 1c34312..b4272d5 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,5 +1,7 @@ #!/bin/sh -l +echo $@ + openapi_python_client_version = $1 openapi_file_path = $2 config_file_path = $3 From c6d1b271bf0fa4109faa28b2a367140d17835b56 Mon Sep 17 00:00:00 2001 From: Ethan Mann Date: Wed, 27 Jan 2021 11:25:03 -0500 Subject: [PATCH 16/23] Fix formatting in entrypoint script --- entrypoint.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index b4272d5..6633af6 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,10 +1,8 @@ #!/bin/sh -l -echo $@ - -openapi_python_client_version = $1 -openapi_file_path = $2 -config_file_path = $3 +openapi_python_client_version=$1 +openapi_file_path=$2 +config_file_path=$3 pip install openapi-python-client==${openapi_python_client_version} From 70339fc8ae7064fde4b7d4306f29d779c8c06622 Mon Sep 17 00:00:00 2001 From: Ethan Mann Date: Wed, 27 Jan 2021 11:57:36 -0500 Subject: [PATCH 17/23] Switched to using pipx for running openapi-python-client --- Dockerfile | 3 +++ entrypoint.sh | 8 +++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9893fd1..ea1d270 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,8 @@ FROM python:3.8 +RUN python -m pip install --upgrade pip +RUN pip install pipx + COPY entrypoint.sh /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh index 6633af6..75182f1 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,13 +1,11 @@ -#!/bin/sh -l +#!/bin/bash openapi_python_client_version=$1 openapi_file_path=$2 config_file_path=$3 -pip install openapi-python-client==${openapi_python_client_version} - if [[ "$config_file_path" == "NOT_SPECIFIED" ]]; then - python -m openapi-python-client generate --path ${openapi_file_path} + pipx run --spec openapi-python-client==${openapi_python_client_version} openapi-python-client generate --path ${openapi_file_path} else - python -m openapi-python-client generate --path ${openapi_file_path} --config ${config_file_path} + pipx run --spec openapi-python-client==${openapi_python_client_version} openapi-python-client --config ${config_file_path} generate --path ${openapi_file_path} fi \ No newline at end of file From 2881de60c7744ae55caa8e1799a6fb40d2f59c82 Mon Sep 17 00:00:00 2001 From: Ethan Mann Date: Wed, 27 Jan 2021 12:00:34 -0500 Subject: [PATCH 18/23] Trying to fix user permissions again --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index ea1d270..e33c7de 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,8 @@ FROM python:3.8 RUN python -m pip install --upgrade pip RUN pip install pipx +USER 1001 + COPY entrypoint.sh /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file From e20bca25b5c5510c5561c3f09a11bf075c99fff9 Mon Sep 17 00:00:00 2001 From: Ethan Mann Date: Wed, 27 Jan 2021 13:44:35 -0500 Subject: [PATCH 19/23] Cleaned up the entrypoint script a bit --- action.yml | 2 +- entrypoint.sh | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index b1d0ed8..c3fbfc8 100644 --- a/action.yml +++ b/action.yml @@ -8,7 +8,7 @@ inputs: openapi-python-client-version: description: "The version of openapi-python-client to use when generating the client package" required: false - default: "latest" + default: NOT_SPECIFIED openapi-file: description: The path to the openapi document to generate a client library for required: false diff --git a/entrypoint.sh b/entrypoint.sh index 75182f1..0c31516 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -4,8 +4,16 @@ openapi_python_client_version=$1 openapi_file_path=$2 config_file_path=$3 -if [[ "$config_file_path" == "NOT_SPECIFIED" ]]; then - pipx run --spec openapi-python-client==${openapi_python_client_version} openapi-python-client generate --path ${openapi_file_path} +if [[ "$openapi_python_client_version" != "NOT_SPECIFIED" ]]; then + version_arg="--spec openapi-python-client==${openapi_python_client_version}" else - pipx run --spec openapi-python-client==${openapi_python_client_version} openapi-python-client --config ${config_file_path} generate --path ${openapi_file_path} -fi \ No newline at end of file + version_arg="" +fi + +if [[ "$config_file_path" != "NOT_SPECIFIED" ]]; then + config_arg="--config ${config_file_path}" +else + config_arg="" +fi + +pipx run ${version_arg} openapi-python-client ${config_arg} generate --path ${openapi_file_path} \ No newline at end of file From 040c8b964ec1b748a4e115dc9c99dc3e314ccf98 Mon Sep 17 00:00:00 2001 From: Ethan Mann Date: Fri, 29 Jan 2021 11:58:39 -0500 Subject: [PATCH 20/23] Added documentation/usages details to README --- README.md | 47 ++++++++++++++++++++++++++++++++++++++++++++++- action.yml | 4 ++-- 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a8540eb..afd4aff 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,47 @@ # openapi-python-client-action -GitHub Action to generate a python client package from an openapi spec +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 + +## Inputs + +### `openapi-python-client-version` + +The version of the openapi-python-client package to use to generate the python client. If unspecified the latest released version will be used. + +### `openapi-file` + +The path (with respect to the current directory/the workspace) to the openapi document (both json and yaml are supported). Defaults to just "openapi.json" i.e. a file in the current directory called openapi.json. + +### `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 + +## Outputs + +No outputs are returned. +The generated client is placed in the current directory. The name of the package (unless configured differently) will be `title-client` where "title" comes from the field with the same name within the `info` section of the openapi document. + +## Example usage +```yaml +jobs: + generate-python-client: + runs-on: ubuntu-latest + name: Example + steps: + + # Checkout your code + - name: Checkout + uses: actions/checkout@v2 + + # Generate your openapi document (if you don't write it manually) + + # 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@main + + # Do something with the generated client (likely publishing it somewhere) + # Here we assume that the info/title in the openapi document was "example-project" + - name: Do something with the client + run: | + cd example-project-client +``` \ No newline at end of file diff --git a/action.yml b/action.yml index c3fbfc8..949b0ea 100644 --- a/action.yml +++ b/action.yml @@ -1,5 +1,5 @@ -name: "Generate python client package for openapi spec" -description: "" +name: "Generate A Python Client Package From An OpenAPI file" +description: "Generates a python client package from an openapifile using the openapi-python-client project" branding: icon: "target" color: "green" From 209f171902fefe5acff4132beb6aa87dd50999c8 Mon Sep 17 00:00:00 2001 From: Ethan Mann Date: Fri, 29 Jan 2021 13:15:46 -0500 Subject: [PATCH 21/23] Added a note about the "USER 1001" in the Dockerfile --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e33c7de..b87b9e3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,8 @@ FROM python:3.8 RUN python -m pip install --upgrade pip RUN pip install pipx -USER 1001 +# Sets the user to the same user that the workflow runner uses so that it can access the generated client +USER 1001 COPY entrypoint.sh /entrypoint.sh From b10f6087e0aad1546761c9a903ebbfa484a0a6ae Mon Sep 17 00:00:00 2001 From: Ethan Mann Date: Mon, 1 Feb 2021 17:22:28 -0500 Subject: [PATCH 22/23] Apply suggestions from code review Co-authored-by: Dylan Anthony <43723790+dbanty@users.noreply.github.com> --- README.md | 8 ++++---- action.yml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index afd4aff..49c6b68 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,15 @@ # 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/triaxtec/openapi-python-client) - generates a modern Python client package from an OpenAPI document ## Inputs ### `openapi-python-client-version` -The version of the openapi-python-client package to use to generate the python client. If unspecified the latest released version will be used. +The version of the openapi-python-client package to use. If unspecified the latest released version will be used. ### `openapi-file` -The path (with respect to the current directory/the workspace) to the openapi document (both json and yaml are supported). Defaults to just "openapi.json" i.e. a file in the current directory called openapi.json. +The path (with respect to the current directory/the workspace) to the OpenAPI document (both JSON and YAML are supported). Defaults to just "openapi.json" i.e. a file in the current directory called openapi.json. ### `config-file` @@ -44,4 +44,4 @@ jobs: - name: Do something with the client run: | cd example-project-client -``` \ No newline at end of file +``` diff --git a/action.yml b/action.yml index 949b0ea..03160a1 100644 --- a/action.yml +++ b/action.yml @@ -1,5 +1,5 @@ name: "Generate A Python Client Package From An OpenAPI file" -description: "Generates a python client package from an openapifile using the openapi-python-client project" +description: "Generates a Python client package from an OpenAPI document using the openapi-python-client project" branding: icon: "target" color: "green" @@ -24,4 +24,4 @@ runs: args: - ${{ inputs.openapi-python-client-version }} - ${{ inputs.openapi-file }} - - ${{ inputs.config-file }} \ No newline at end of file + - ${{ inputs.config-file }} From 185351acd000d7f4bcdd16e01f6bc615502ffd05 Mon Sep 17 00:00:00 2001 From: Ethan Mann Date: Mon, 1 Feb 2021 17:48:07 -0500 Subject: [PATCH 23/23] Added support for specifying a url instead of a file path for the openapi doc --- README.md | 6 +++++- action.yml | 11 ++++++++--- entrypoint.sh | 10 ++++++++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 49c6b68..a9364eb 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,10 @@ The version of the openapi-python-client package to use. If unspecified the late The path (with respect to the current directory/the workspace) to the OpenAPI document (both JSON and YAML are supported). Defaults to just "openapi.json" i.e. a file in the current directory called openapi.json. +### `openapi-url` + +The url of the OpenAPI document. Overrides `openapi-file` - If unspecified the value of the `openapi-file` input (which defaults to just `openapi.json`) will be used to generate the client. + ### `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 @@ -37,7 +41,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@main + uses: triaxtec/openapi-python-client-action@v1 # 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 03160a1..9b9b625 100644 --- a/action.yml +++ b/action.yml @@ -6,15 +6,19 @@ branding: inputs: openapi-python-client-version: - description: "The version of openapi-python-client to use when generating the client package" + description: The version of openapi-python-client to use required: false default: NOT_SPECIFIED openapi-file: - description: The path to the openapi document to generate a client library for + description: The path to the OpenAPI document to generate a client library for e.g. docs/openapi.json required: false default: openapi.json + openapi-url: + description: The url of the OpenAPI document to generate a client library for e.g. https://petstore3.swagger.io/api/v3/openapi.json + required: false + default: NOT_SPECIFIED config-file: - description: "Path to the config file to be passed along to openapi-python-client" + description: Path to the config file to be passed along to openapi-python-client required: false default: NOT_SPECIFIED @@ -24,4 +28,5 @@ runs: args: - ${{ inputs.openapi-python-client-version }} - ${{ inputs.openapi-file }} + - ${{ inputs.openapi-url }} - ${{ inputs.config-file }} diff --git a/entrypoint.sh b/entrypoint.sh index 0c31516..0dbaa2a 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,7 +2,8 @@ openapi_python_client_version=$1 openapi_file_path=$2 -config_file_path=$3 +openapi_url=$3 +config_file_path=$4 if [[ "$openapi_python_client_version" != "NOT_SPECIFIED" ]]; then version_arg="--spec openapi-python-client==${openapi_python_client_version}" @@ -16,4 +17,9 @@ else config_arg="" fi -pipx run ${version_arg} openapi-python-client ${config_arg} generate --path ${openapi_file_path} \ No newline at end of file +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}" +fi + +pipx run ${version_arg} openapi-python-client ${config_arg} generate ${openapi_document_path_or_url_arg} \ No newline at end of file