From 2c1c8921cc241aa2cff7c124069162c84d644393 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 21 Sep 2025 01:40:57 +0000 Subject: [PATCH 1/5] Initial plan From 82ebf708aad7ff18e66a2bae48844cafe88a7a35 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 21 Sep 2025 01:46:01 +0000 Subject: [PATCH 2/5] Add java-options support for handling large YAML documents Co-authored-by: dbanty <43723790+dbanty@users.noreply.github.com> --- .github/workflows/checks.yml | 10 ++++++++++ README.md | 9 +++++++++ __pycache__/entrypoint.cpython-312.pyc | Bin 0 -> 1539 bytes action.yml | 5 ++++- entrypoint.py | 7 ++++++- 5 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 __pycache__/entrypoint.cpython-312.pyc diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 96e2809..e6eb1f4 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -97,3 +97,13 @@ jobs: openapi-file: test_data/openapi.json command-args: --model-name-prefix=BLAH - run: test -f rust-client/src/models/blah_a_model.rs + test-java-options: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.2.2 + - uses: openapi-generators/openapitools-generator-action@v1 + with: + generator: rust + openapi-file: test_data/openapi.json + java-options: "-DmaxYamlCodePoints=99999999" + - run: cd rust-client diff --git a/README.md b/README.md index 37dde13..14c7bcc 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,15 @@ See user-defined [templates](https://openapi-generator.tech/docs/templating#modi Additional arguments to pass through to the [generate](https://openapi-generator.tech/docs/usage#generate) command. +### `java-options` + +Optional, Java options to pass to the generator via the `_JAVA_OPTIONS` environment variable. This is useful for handling large OpenAPI documents by increasing limits. For example, to increase the YAML code points limit: + +```yaml +with: + java-options: "-DmaxYamlCodePoints=99999999" +``` + ## Outputs No outputs are returned. The generated client is placed in the current directory. The name of the package (unless configured differently) will be `generator-name-client` where "generator-name" is (unsurprisingly) the name of the generator used to generate the client. diff --git a/__pycache__/entrypoint.cpython-312.pyc b/__pycache__/entrypoint.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..aedbca5fdbb566d563f175e97acae45d3582eef9 GIT binary patch literal 1539 zcma)5Pi)&{6#s0;&L2B}*QV>rz-cE+R=jKsu~J5*u0*5RXty z)pnIYTbT2y~Fc5kBMy zAA=+8a)e!uQRpCtBZ}f~gq7K1^37ZIeHb0ytzVBPK8pVYjLGru$9Bkm)v$&D^^?i* zznox_uswN6Rh_4V3biC@GX-eCa?O2K6}b_TwfqJ|JgSy?p~^ST&RsZv{sJ!usD#Z! z4QnT0PGaw|8oODoH(pHBA({NsB>sz=N<{CokHA(9N(@bE%`Z^U^)JF1*&c!j*G zz_QVZ9T7`8uPVG_^R6}cEWSLguR~Q`PR8wkUVTtOS{~{;qVR-lO0Vn4<9MW|BmDUQ z#5jn^+5SO48nUDPDdiBXXu4u(sBUwEkW!Kg&<-Bf<_xJ|b6N$KrHYbUQ&ecPLsUho z&E~c8no{UzI0Kd{D!y_KPub>*QccQf6+_X=y1Oymrt&2jcWp?>&>!L@*q)-Mlx+{( zRE+PyYuqa6-A%1)C78l1#Pf4^lo}`+nx^W)VQ+$zcewv2i${y<6|7>MtJHhG%Oy>& zs&F1nVJ+t?*IU>gPy|7|0u!&m$nW6vfd_m+-XsrjL56Hbn@d)hZ@=FOKL6&&yOs#8 zf{s%);)+v|CYQ*4U;J_H$);Jf_{>iqS-0e0uR$xbX02^nOub3{!vIgjyxzXLJ2KM^ zMp|hrdZzt#d%2Ua0v|RP_x)UpZr#KhRw&VqwlBBOb%>78dFKbe#blaP*Ue|mq&Z=| z^+D(3&dl>W7L#sL`&7uB-lfL7?AS|o@&!BDzPQIucgJV8uW!#=V{OLb_DQ1V#iz56XTSaI$-EVtboKFM2>MaBHDzY^=u^Le36#Ja`4><)!K?rP literal 0 HcmV?d00001 diff --git a/action.yml b/action.yml index 397e200..df7f8a3 100644 --- a/action.yml +++ b/action.yml @@ -39,9 +39,12 @@ inputs: command-args: description: Optional, additional arguments to pass through to the generator. required: false + java-options: + description: Optional, Java options to pass to the generator via the _JAVA_OPTIONS environment variable (e.g., "-DmaxYamlCodePoints=99999999"). + required: false runs: using: composite steps: - shell: bash - run: python ${{ github.action_path }}/entrypoint.py ${{ inputs.generator }} ${{ inputs.docker-repository }} ${{ inputs.docker-image }} ${{ inputs.generator-tag }} ${{ inputs.openapi-file }} ${{ inputs.openapi-url }} ${{ inputs.config-file }} ${{ inputs.template-dir }} ${{ inputs.command-args}} + run: python ${{ github.action_path }}/entrypoint.py ${{ inputs.generator }} ${{ inputs.docker-repository }} ${{ inputs.docker-image }} ${{ inputs.generator-tag }} ${{ inputs.openapi-file }} ${{ inputs.openapi-url }} ${{ inputs.config-file }} ${{ inputs.template-dir }} ${{ inputs.java-options }} ${{ inputs.command-args}} diff --git a/entrypoint.py b/entrypoint.py index 11fa6ee..9844f1f 100755 --- a/entrypoint.py +++ b/entrypoint.py @@ -2,9 +2,14 @@ from sys import argv from os import getenv, getuid -(_, generator, docker_repository, docker_image, generator_tag, openapi_file, openapi_url, config_file, template_dir, *args) = argv +(_, generator, docker_repository, docker_image, generator_tag, openapi_file, openapi_url, config_file, template_dir, java_options, *args) = argv cmd = f"docker run -u {getuid()}:1001 --rm --workdir /github/workspace -v {getenv('GITHUB_WORKSPACE')}:/github/workspace" + +# Add Java options as environment variable if provided +if java_options and java_options != "UNSET": + cmd = f"{cmd} -e _JAVA_OPTIONS='{java_options}'" + cmd = f"{cmd} {docker_repository}/{docker_image}:{generator_tag} generate" cmd = f"{cmd} -g {generator} -o /github/workspace/{generator}-client" From d571e1ef6e3770c9443539d9cb5083d325519baf Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 21 Sep 2025 01:46:19 +0000 Subject: [PATCH 3/5] Remove __pycache__ and update .gitignore --- .gitignore | 1 + __pycache__/entrypoint.cpython-312.pyc | Bin 1539 -> 0 bytes 2 files changed, 1 insertion(+) delete mode 100644 __pycache__/entrypoint.cpython-312.pyc diff --git a/.gitignore b/.gitignore index 9f11b75..2483976 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .idea/ +__pycache__/ diff --git a/__pycache__/entrypoint.cpython-312.pyc b/__pycache__/entrypoint.cpython-312.pyc deleted file mode 100644 index aedbca5fdbb566d563f175e97acae45d3582eef9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1539 zcma)5Pi)&{6#s0;&L2B}*QV>rz-cE+R=jKsu~J5*u0*5RXty z)pnIYTbT2y~Fc5kBMy zAA=+8a)e!uQRpCtBZ}f~gq7K1^37ZIeHb0ytzVBPK8pVYjLGru$9Bkm)v$&D^^?i* zznox_uswN6Rh_4V3biC@GX-eCa?O2K6}b_TwfqJ|JgSy?p~^ST&RsZv{sJ!usD#Z! z4QnT0PGaw|8oODoH(pHBA({NsB>sz=N<{CokHA(9N(@bE%`Z^U^)JF1*&c!j*G zz_QVZ9T7`8uPVG_^R6}cEWSLguR~Q`PR8wkUVTtOS{~{;qVR-lO0Vn4<9MW|BmDUQ z#5jn^+5SO48nUDPDdiBXXu4u(sBUwEkW!Kg&<-Bf<_xJ|b6N$KrHYbUQ&ecPLsUho z&E~c8no{UzI0Kd{D!y_KPub>*QccQf6+_X=y1Oymrt&2jcWp?>&>!L@*q)-Mlx+{( zRE+PyYuqa6-A%1)C78l1#Pf4^lo}`+nx^W)VQ+$zcewv2i${y<6|7>MtJHhG%Oy>& zs&F1nVJ+t?*IU>gPy|7|0u!&m$nW6vfd_m+-XsrjL56Hbn@d)hZ@=FOKL6&&yOs#8 zf{s%);)+v|CYQ*4U;J_H$);Jf_{>iqS-0e0uR$xbX02^nOub3{!vIgjyxzXLJ2KM^ zMp|hrdZzt#d%2Ua0v|RP_x)UpZr#KhRw&VqwlBBOb%>78dFKbe#blaP*Ue|mq&Z=| z^+D(3&dl>W7L#sL`&7uB-lfL7?AS|o@&!BDzPQIucgJV8uW!#=V{OLb_DQ1V#iz56XTSaI$-EVtboKFM2>MaBHDzY^=u^Le36#Ja`4><)!K?rP From a8324336a770f837b83bf067673930face37b8f3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 21 Sep 2025 01:53:33 +0000 Subject: [PATCH 4/5] Replace java-options with generic env parameter for environment variables Co-authored-by: dbanty <43723790+dbanty@users.noreply.github.com> --- .github/workflows/checks.yml | 4 ++-- README.md | 24 +++++++++++++++++++++--- action.yml | 6 +++--- entrypoint.py | 13 +++++++++---- 4 files changed, 35 insertions(+), 12 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index e6eb1f4..2b28421 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -97,7 +97,7 @@ jobs: openapi-file: test_data/openapi.json command-args: --model-name-prefix=BLAH - run: test -f rust-client/src/models/blah_a_model.rs - test-java-options: + test-env-vars: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4.2.2 @@ -105,5 +105,5 @@ jobs: with: generator: rust openapi-file: test_data/openapi.json - java-options: "-DmaxYamlCodePoints=99999999" + env: "_JAVA_OPTIONS=-DmaxYamlCodePoints=99999999" - run: cd rust-client diff --git a/README.md b/README.md index 14c7bcc..61d3163 100644 --- a/README.md +++ b/README.md @@ -43,13 +43,31 @@ See user-defined [templates](https://openapi-generator.tech/docs/templating#modi Additional arguments to pass through to the [generate](https://openapi-generator.tech/docs/usage#generate) command. -### `java-options` +### `env` -Optional, Java options to pass to the generator via the `_JAVA_OPTIONS` environment variable. This is useful for handling large OpenAPI documents by increasing limits. For example, to increase the YAML code points limit: +Optional, environment variables to pass to the generator. Provide as key=value pairs, one per line or separated by spaces. This is useful for handling large OpenAPI documents or configuring the generator environment. +Examples: + +For handling large YAML files: +```yaml +with: + env: "_JAVA_OPTIONS=-DmaxYamlCodePoints=99999999" +``` + +Multiple environment variables (space separated): +```yaml +with: + env: "_JAVA_OPTIONS=-DmaxYamlCodePoints=99999999 NODE_ENV=production" +``` + +Multiple environment variables (multi-line): ```yaml with: - java-options: "-DmaxYamlCodePoints=99999999" + env: | + _JAVA_OPTIONS=-DmaxYamlCodePoints=99999999 + NODE_ENV=production + DEBUG=true ``` ## Outputs diff --git a/action.yml b/action.yml index df7f8a3..c6f339c 100644 --- a/action.yml +++ b/action.yml @@ -39,12 +39,12 @@ inputs: command-args: description: Optional, additional arguments to pass through to the generator. required: false - java-options: - description: Optional, Java options to pass to the generator via the _JAVA_OPTIONS environment variable (e.g., "-DmaxYamlCodePoints=99999999"). + env: + description: Optional, environment variables to pass to the generator. Provide as key=value pairs, one per line or separated by spaces. required: false runs: using: composite steps: - shell: bash - run: python ${{ github.action_path }}/entrypoint.py ${{ inputs.generator }} ${{ inputs.docker-repository }} ${{ inputs.docker-image }} ${{ inputs.generator-tag }} ${{ inputs.openapi-file }} ${{ inputs.openapi-url }} ${{ inputs.config-file }} ${{ inputs.template-dir }} ${{ inputs.java-options }} ${{ inputs.command-args}} + run: python ${{ github.action_path }}/entrypoint.py ${{ inputs.generator }} ${{ inputs.docker-repository }} ${{ inputs.docker-image }} ${{ inputs.generator-tag }} ${{ inputs.openapi-file }} ${{ inputs.openapi-url }} ${{ inputs.config-file }} ${{ inputs.template-dir }} ${{ inputs.env }} ${{ inputs.command-args}} diff --git a/entrypoint.py b/entrypoint.py index 9844f1f..28cebbf 100755 --- a/entrypoint.py +++ b/entrypoint.py @@ -2,13 +2,18 @@ from sys import argv from os import getenv, getuid -(_, generator, docker_repository, docker_image, generator_tag, openapi_file, openapi_url, config_file, template_dir, java_options, *args) = argv +(_, generator, docker_repository, docker_image, generator_tag, openapi_file, openapi_url, config_file, template_dir, env_vars, *args) = argv cmd = f"docker run -u {getuid()}:1001 --rm --workdir /github/workspace -v {getenv('GITHUB_WORKSPACE')}:/github/workspace" -# Add Java options as environment variable if provided -if java_options and java_options != "UNSET": - cmd = f"{cmd} -e _JAVA_OPTIONS='{java_options}'" +# Add environment variables if provided +if env_vars and env_vars != "UNSET": + # Parse environment variables - support both multiline and space-separated formats + # Split by both newlines and spaces, then filter out empty strings + env_pairs = [pair.strip() for pair in env_vars.replace('\n', ' ').split() if pair.strip()] + for env_pair in env_pairs: + if '=' in env_pair: + cmd = f"{cmd} -e '{env_pair}'" cmd = f"{cmd} {docker_repository}/{docker_image}:{generator_tag} generate" cmd = f"{cmd} -g {generator} -o /github/workspace/{generator}-client" From bfb582b162415b2c9d407c091f2b9493899af031 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 21 Sep 2025 03:38:29 +0000 Subject: [PATCH 5/5] Use GitHub Actions env: feature instead of custom env input parameter Co-authored-by: dbanty <43723790+dbanty@users.noreply.github.com> --- .github/workflows/checks.yml | 6 +++-- README.md | 46 +++++++++++++++++++++++------------- action.yml | 5 +--- entrypoint.py | 25 ++++++++++++-------- 4 files changed, 49 insertions(+), 33 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 2b28421..cf2029c 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -101,9 +101,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4.2.2 - - uses: openapi-generators/openapitools-generator-action@v1 + - name: Generate with environment variables + env: + _JAVA_OPTIONS: "-DmaxYamlCodePoints=99999999" + uses: openapi-generators/openapitools-generator-action@v1 with: generator: rust openapi-file: test_data/openapi.json - env: "_JAVA_OPTIONS=-DmaxYamlCodePoints=99999999" - run: cd rust-client diff --git a/README.md b/README.md index 61d3163..82b8bc9 100644 --- a/README.md +++ b/README.md @@ -43,31 +43,43 @@ See user-defined [templates](https://openapi-generator.tech/docs/templating#modi Additional arguments to pass through to the [generate](https://openapi-generator.tech/docs/usage#generate) command. -### `env` +## Environment Variables -Optional, environment variables to pass to the generator. Provide as key=value pairs, one per line or separated by spaces. This is useful for handling large OpenAPI documents or configuring the generator environment. +The action automatically passes through certain environment variables to the OpenAPI Generator container. You can set these using GitHub Actions' built-in `env:` feature. -Examples: +### Supported Environment Variables -For handling large YAML files: -```yaml -with: - env: "_JAVA_OPTIONS=-DmaxYamlCodePoints=99999999" -``` +The following environment variables are automatically passed through when set: +- `_JAVA_OPTIONS` - Java runtime options (useful for handling large YAML files) +- `JAVA_OPTS` - Additional Java options +- `NODE_ENV` - Node.js environment setting +- `DEBUG` - Debug mode flag +- `OPENAPI_GENERATOR_VERSION` - Override generator version -Multiple environment variables (space separated): +### Usage Examples + +For handling large YAML files: ```yaml -with: - env: "_JAVA_OPTIONS=-DmaxYamlCodePoints=99999999 NODE_ENV=production" +- name: Generate Client + env: + _JAVA_OPTIONS: "-DmaxYamlCodePoints=99999999" + uses: openapi-generators/openapitools-generator-action@v1 + with: + generator: powershell + openapi-file: large-redfish-spec.yaml ``` -Multiple environment variables (multi-line): +Multiple environment variables: ```yaml -with: - env: | - _JAVA_OPTIONS=-DmaxYamlCodePoints=99999999 - NODE_ENV=production - DEBUG=true +- name: Generate Client + env: + _JAVA_OPTIONS: "-DmaxYamlCodePoints=99999999" + NODE_ENV: "production" + DEBUG: "true" + uses: openapi-generators/openapitools-generator-action@v1 + with: + generator: typescript-angular + openapi-file: spec.yaml ``` ## Outputs diff --git a/action.yml b/action.yml index c6f339c..397e200 100644 --- a/action.yml +++ b/action.yml @@ -39,12 +39,9 @@ inputs: command-args: description: Optional, additional arguments to pass through to the generator. required: false - env: - description: Optional, environment variables to pass to the generator. Provide as key=value pairs, one per line or separated by spaces. - required: false runs: using: composite steps: - shell: bash - run: python ${{ github.action_path }}/entrypoint.py ${{ inputs.generator }} ${{ inputs.docker-repository }} ${{ inputs.docker-image }} ${{ inputs.generator-tag }} ${{ inputs.openapi-file }} ${{ inputs.openapi-url }} ${{ inputs.config-file }} ${{ inputs.template-dir }} ${{ inputs.env }} ${{ inputs.command-args}} + run: python ${{ github.action_path }}/entrypoint.py ${{ inputs.generator }} ${{ inputs.docker-repository }} ${{ inputs.docker-image }} ${{ inputs.generator-tag }} ${{ inputs.openapi-file }} ${{ inputs.openapi-url }} ${{ inputs.config-file }} ${{ inputs.template-dir }} ${{ inputs.command-args}} diff --git a/entrypoint.py b/entrypoint.py index 28cebbf..f6fe0bb 100755 --- a/entrypoint.py +++ b/entrypoint.py @@ -1,19 +1,24 @@ from subprocess import call from sys import argv -from os import getenv, getuid +from os import getenv, getuid, environ -(_, generator, docker_repository, docker_image, generator_tag, openapi_file, openapi_url, config_file, template_dir, env_vars, *args) = argv +(_, generator, docker_repository, docker_image, generator_tag, openapi_file, openapi_url, config_file, template_dir, *args) = argv cmd = f"docker run -u {getuid()}:1001 --rm --workdir /github/workspace -v {getenv('GITHUB_WORKSPACE')}:/github/workspace" -# Add environment variables if provided -if env_vars and env_vars != "UNSET": - # Parse environment variables - support both multiline and space-separated formats - # Split by both newlines and spaces, then filter out empty strings - env_pairs = [pair.strip() for pair in env_vars.replace('\n', ' ').split() if pair.strip()] - for env_pair in env_pairs: - if '=' in env_pair: - cmd = f"{cmd} -e '{env_pair}'" +# Pass through environment variables that are commonly needed for OpenAPI generation +# This allows users to set these via GitHub Actions env: instead of custom input +env_vars_to_pass = [ + '_JAVA_OPTIONS', + 'JAVA_OPTS', + 'NODE_ENV', + 'DEBUG', + 'OPENAPI_GENERATOR_VERSION' +] + +for env_var in env_vars_to_pass: + if env_var in environ: + cmd = f"{cmd} -e {env_var}='{environ[env_var]}'" cmd = f"{cmd} {docker_repository}/{docker_image}:{generator_tag} generate" cmd = f"{cmd} -g {generator} -o /github/workspace/{generator}-client"