OpenAPITools / OpenAPITools/openapi-generator
[BUG][JAVASCRIPT] Node scope in projectName generates code that is unusable (e.g. projectName=@mypackagescope/mypackagename)
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
If you want use a scoped node package name, then the generator will generate unusable code.
Actual
openapi-generator generate -i .\api-with-examples.yaml -g javascript -o generated-sources/openapi --additional-properties="projectName=@mypackagescope/mypackagename
Will generate the README.md excerpt
var @MypackagescopeMypackagename = require('@mypackagescope/mypackagename');
var api = new @MypackagescopeMypackagename.DefaultApi()
Expected
Expected input is up for discussion. What I would do is add a nodeScope parameter so that
--additional-properties="nodeScopeName=mypackagescope,projectName=mypackagename
generates
var Mypackagename = require('@mypackagescope/mypackagename');
var api = new Mypackagename.DefaultApi()
openapi-generator version
4.2.0
OpenAPI declaration file content or url
openapi: "3.0.0"
info:
title: Simple API overview
version: 2.0.0
paths:
/:
get:
operationId: listVersionsv2
summary: List API versions
responses:
'200':
description: |-
200 response
content:
application/json:
examples:
foo:
value: { }
Command line used for generation
Actual
openapi-generator generate -i .\api-with-examples.yaml -g javascript -o generated-sources/openapi --additional-properties="projectName=@mypackagescope/mypackagename"
Expected (suggested)
openapi-generator generate -i .\api-with-examples.yaml -g javascript -o generated-sources/openapi --additional-properties="nodeScope=mypackagescope,projectName=mypackagename"
Steps to reproduce
Run the command on any valid specification.yaml. Observe the generated README and code.
Related issues/PRs
Suggest a fix
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the documented openapi-generator command with the supplied OpenAPI declaration and inspect the generated README and JavaScript code. Compare the scoped projectName output with the suggested nodeScope and projectName inputs; done means the generated require statement and client variable use valid JavaScript identifiers while retaining the scoped package name.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100