OpenAPITools / OpenAPITools/openapi-generator

Can't get Templates to work

Open
#7,450 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug Server: C-Sharp
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

I think this is more of a problem with documentation or my stupidity, and I apologize if this has been answered before, (but my search didn't reveal an easy answer) but I can't get Templates noticed with my AspNetCore project

I installed OpenApi-generator with NPM and I can see the openapi-generator jar file in C:\Users\robera22\AppData\Roaming\npm\node_modules@openapitools\openapi-generator-cli\bin.

If I make changes to this (WinZip, don't unpack, change e.g. aspnetcore/3.0/Controller.mustache, save mustache, save zip) then generation works with my command line and I can see the changes I have made.

openapi-generator generate ^
-i Planning\OpenApi\ToolboxV3\MmtBatchWizard.v1.yaml ^
-g aspnetcore ^
-o Servers\v30Local4 ^
-t Servers\Templates ^
--additional-properties=^
aspnetCoreVersion=3.0,^
operationIsAsync=true,^
packageName=Medtronic.Toolbox.MmtBatchWizard,^
packageTitle=MedtronicToolboxSandbox,^
packageVersion=3.0

However this is horribly cumbersome, and takes forever to re-jar the large openapi-generator file

The documentation suggests that I should be able to specify single templates so I set up a Template folder.

First I placed a single amended Mustache File in there (Controller.mustache), no effect
Then I copied the whole aspnetcore/3.0 folder there
Then the aspnetcore
Then the openapi-generator folder
Then the openapi-generator.jar file

None of these had any effect. Still picking up the amendments in the npm/@openapitools

What am I doing wrong in what should be a very simple use case

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the documented -t option and the command shown in the issue, then trace how the npm-installed generator locates aspnetcore templates. Compare that behavior with the amended Controller.mustache and the template directory layouts the reporter tried. Done means documenting or correcting the lookup behavior so a single customized template is used without re-jarring the generator.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, nodejs
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.