Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to provide custom files for generation [BUG] #668

Open
ngarg-vail opened this issue Nov 1, 2022 · 1 comment
Open

Unable to provide custom files for generation [BUG] #668

ngarg-vail opened this issue Nov 1, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@ngarg-vail
Copy link

ngarg-vail commented Nov 1, 2022

🐛 Bug Report:

Describe the bug

The openapi generator specifies the ability to provide custom files/templates (https://openapi-generator.tech/docs/customization).
This feature does not work with the current version of the CLI.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Install latest version of openapi-generator-cli (currently 5.4.0) npm install [email protected]

  2. Provide the following for the openapitools.json file (note the files keyword), e.g.

    {
        "$schema": "/path/to/schema",
        "generator-cli": {
            "version": "5.4.0",
            "generators": {
                 "nodejs": {
                     "templateDir": "#{cwd}/nodejs/templates",
                     "generator-name": "typescript",
                     "output": "#{cwd}/nodejs/sdk",
                     "inputSpec": "#{cwd}/openapi.json",
                     "additionalProperties": {
                        "esTargetVersion": "ES2020",
                        "moduleResolution": "nodejs",
                        "framework": "fetch-api",
                        "platform": "node",
                        "license": "MIT",
                        "useInversify": false,
                        "legacyDiscriminatorBehavior": false
                     },
                     "files": {
                         "api_test.mustache": {
                            "templateType": "ApiTests",
                            "destinationFilename": "spec/api_test.spec.ts"
                         }
                       }
                    }
                 }
            }
        }
    }
    
  3. Execute the generator
    openapi-generator-cli generate --generator-key nodejs

  4. See error

[[nodejs] #{cwd}/openapi.json] [error] Found unexpected parameters: [--files=api_test.mustache=[object Object]]
[[nodejs] #{cwd}/openapi.json] 
[[nodejs] #{cwd}/openapi.json] See 'openapi-generator-cli help' for usage.

  java -jar "node_modules/@openapitools/openapi-generator-cli/versions/5.4.0.jar" generate
--input-spec="/openapi.json"
--template-dir="/openapi-spec/nodejs/templates"
--generator-name="typescript" 
--output="/nodejs/sdk" 
--additional-properties="esTargetVersion=ES2020,moduleResolution=nodejs,framework=fetch-api,platform=node,license=MIT,useInversify=false,legacyDiscriminatorBehavior=false" 
--files="api_test.mustache=[object Object]" exited with code 1

Expected behavior

the "files" keyword gets resolved properly and all sub-properties are provided to the cli.

Operation System (please complete the following information):

  • OS: MacOS
  • Version 12.6.1

Package System (please complete the following information):

  • Version 5.4.0

Additional context

The typescript generator doesn't ship with a test runtime, so I was in the process of using the customization feature - ran into this instead.

@ngarg-vail ngarg-vail added the bug Something isn't working label Nov 1, 2022
@HarisSpahija
Copy link

Is there any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants