swagger-api / swagger-api/swagger-codegen
[Python] ProjectName not picked up from command line argument
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
Thanks in advance & apologies if I'm making some obvious mistake; pretty new with Swagger. Similar if I've missed the documentation explaining this; I've not been able to find it.
I am trying to generate a python client without using a config file as input (CI pipelines reasons), but am not meeting with success. I have tried tweaking my command a lot to no avail, and am not familiar enough with java to dig into it effectively. Opening an issue based on "(If -D{optionName} does not work, please open a ticket and we'll look into it)" at https://github.com/swagger-api/swagger-codegen#getting-started.
Swagger-codegen version
3.0.25
Swagger declaration file content or url
I don't believe it's applicable but for completeness I have a file openapi.json used as the input: https://gist.github.com/rhotchkiss/dd36a38e1645c1118bcb1015ea16dbff
Command line used for generation
The command line not acting as I expect is:
java -jar swagger-codegen-cli.jar generate -i openapi.json -l python -o ./python-api_cli -DpackageName="package_name" -DprojectName="project_name" -DpackageVersion="0.0.1_alpha"
Steps to reproduce
Given a file api_config.json, the contents of which is:
{
"projectName": "project_name",
"packageName":"package_name",
"packageVersion":"0.0.1_alpha"
}
I can run:
java -jar swagger-codegen-cli.jar generate -i openapi.json -l python -o ./python-api_config -c api_config.json
To get my desired output. Notably in /python-api_config/setup.py I see
NAME = "project_name"
VERSION = "0.0.1_alpha"
I am expecting to see the same in /python-api_cli/setup.py if I run:
java -jar swagger-codegen-cli.jar generate -i openapi.json -l python -o ./python-api_cli -DpackageName="package_name" -DprojectName="project_name" -DpackageVersion="0.0.1_alpha"
However I see
NAME = "swagger-client"
VERSION = "0.0.1_alpha"
Suggesting that -DpackageVersion has been picked up, but DprojectName has not been and I am not sure why/if it's expected or what.
NB: I see that both commands give 6 prints of:
"[Thread-1] WARN i.s.c.v.g.DefaultCodegenConfig - String to be sanitized is null. Default to Object"
Related issues/PRs
I have attempted a search mostly on projectName/python and not found anything related.
Suggest a fix/enhancement
N/A Depends on if this is indeed a bug.
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
Reproduce the two swagger-codegen CLI commands with openapi.json and api_config.json, then compare the generated python-api_config/setup.py and python-api_cli/setup.py files. Start by tracing how the Python generator handles projectName, packageName, and packageVersion from command-line properties versus the config file. Done means the CLI-generated setup.py uses the supplied projectName consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, python
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100