Visitar URL original
feat: add `template-dir` argument for custom templates by rcebrian · Pull Request #12 · openapi-generators/openapitools-generator-action · GitHub
Skip to content

feat: add template-dir argument for custom templates - #12

Merged
dbanty merged 9 commits into
openapi-generators:v1from
rcebrian:template-dir
Feb 27, 2022
Merged

dbanty merged 9 commits into
openapi-generators:v1from
rcebrian:template-dir

Conversation

@rcebrian

@rcebrian rcebrian commented Feb 20, 2022 •

Copy link
Copy Markdown
Contributor

Generate template-dir as a new input to include custom template parameter (-t | --template)

  • Tested in my own repository
  • Docs included

Trying to include the templates using 'command-args':

jobs
  generate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: openapi-generators/openapitools-generator-action@v1
        with:
          generator: rust
          openapi-file: test_data/openapi.json
          command-args: |
            -t my-template

Generates an error because the templates path wasn't correct, needing the full path of the workdir, that is not included anywhere, having to access the code to look for it.
With this change, we can use:

jobs
  generate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: openapi-generators/openapitools-generator-action@v1
        with:
          generator: rust
          openapi-file: test_data/openapi.json
          template-dir: my-template

I hope it helps.

@rcebrian
rcebrian marked this pull request as ready for review February 20, 2022 02:31

@dbanty dbanty left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for the contribution! One question I have is where these templates came from. They're too thorough to have been written just for this test (I think), so I assume they were copied from another project which would mean we're in violation of whatever the license was for that project (presumably).

Is it possible to have a simpler (maybe single file) template just for this test? I don't know how strict the openapitools validation is on templates.

@rcebrian rcebrian closed this Feb 20, 2022
@rcebrian rcebrian reopened this Feb 20, 2022
@rcebrian

Copy link
Copy Markdown
Contributor Author

Awesome, thanks for the contribution! One question I have is where these templates came from. They're too thorough to have been written just for this test (I think), so I assume they were copied from another project which would mean we're in violation of whatever the license was for that project (presumably).

Is it possible to have a simpler (maybe single file) template just for this test? I don't know how strict the openapitools validation is on templates.

You're welcome!
I have obtained the templates from the official repository https://github.com/OpenAPITools/openapi-generator which is under the Apache license, so you can use them.

On the other hand, I also tried to generate a minor template, but I got multiple errors and the generated code was not reliable.

@dbanty

dbanty commented Feb 20, 2022

Copy link
Copy Markdown
Contributor

I have obtained the templates from the official repository https://github.com/OpenAPITools/openapi-generator which is under the Apache license, so you can use them.

Great, so if it's Apache I think the rules are we need to include a copy of the license anywhere we've copied the code. So just copying the license into that templates dir is probably okay then.

@rcebrian

Copy link
Copy Markdown
Contributor Author

I have obtained the templates from the official repository https://github.com/OpenAPITools/openapi-generator which is under the Apache license, so you can use them.

Great, so if it's Apache I think the rules are we need to include a copy of the license anywhere we've copied the code. So just copying the license into that templates dir is probably okay then.

Ok, added!

@dbanty dbanty left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks!

@dbanty dbanty changed the title Include custom templates feat: add template-dir argument for custom templates Feb 27, 2022
@dbanty
dbanty merged commit 4b4f4d6 into openapi-generators:v1 Feb 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants