OpenAPITools / OpenAPITools/openapi-generator
[REQ] --import-mapping usage not transparent
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Copy of my comment here on issue #5909
OPENAPI_GENERATOR_VERSION=4.3.1 ./openapi-generator-cli.sh generate \
--input-spec hi.yaml \
--generator-name python \
--additional-properties generateSourceCodeOnly=True \
--template-dir templates \
--type-mappings array=List \
--import-mappings List="from typing import List" \
--import-mappings DateFromISO="from my_package import DateFromISO" \
--output ../mydir
should produce:
listgets typed asList(works)- an import statement
from typing import Listin all files withList(does not work)
Working with custom objects not defined in the schema .yaml file is not transparent at this time. For example, if I have
type = DateFromISO
in my schema file, the generator throws the following warnings multiple times:
WARN o.o.c.languages.PythonClientCodegen - Type DateFromISO not handled properly in toExampleValue
WARN o.o.codegen.DefaultCodegen - Unknown type found in the schema: DateFromISO
I figure the generator would recognise DateFromISO from --import-mappings
Lastly, I am having a hard time finding sample usage of openapi-generator-cli-x.x.x.jar arguments like --import-mappings
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 with the --import-mappings handling in the CLI and the PythonClientCodegen and DefaultCodegen entry points named by the warnings. Reproduce the command with DateFromISO and List, then inspect the generated Python files and the openapi-generator-cli-x.x.x.jar argument documentation. Done means imported custom types are handled without the reported warnings and the --import-mappings usage is documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, python
- Domain
- api, cli, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100