OpenAPITools / OpenAPITools/openapi-generator
[BUG] Typescript/typescript-angular missing import for interfaces generated from additionalProperties
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- What's the version of OpenAPI Generator used?
- Have you search for related issues/PRs?
- What's the actual output vs expected output?
Description
Hi there, I believe I found an issue with generated typescript code for the typescript-angular generator (but I'm also hoping it is configuration.).
I have posted a full example with generated code, it calls compodoc (which attempts to parse all services)
Typescript missing imports for interfaces generated from additionalProperties
openapi-generator version
4.1.2
"@openapitools/openapi-generator-cli": "0.0.19-4.1.2"
OpenAPI declaration file content or url
https://github.com/ltomes/openapi-generator-issue/blob/master/specWithAdditionalProperties.yaml
Command line used for generation
./node_modules/.bin/openapi-generator generate -i ./specWithOutAdditionalProperties.yaml -g typescript-angular -o src --package-name restClient --enable-post-process-file --additional-properties=npmName=restClient,supportsES6=true,withInterfaces=true,enablePostProcessFile=true
Steps to reproduce
I have created a minimal repo to reproduce the issue: https://github.com/ltomes/openapi-generator-issue
npm install, any node 10+ versionnpm run build:additionalObserve that the generated code (src/api/default.service.ts) is missing any imports toadditionalPropertiesfrom the schema/they are not imported as type interfaces.
Related issues/PRs
I see other users getting generation issues now and again, but I don't see this exact issue reported.
Suggest a fix
additionalProperties should be evaluated for imports the same way properties are (Or I have misconfigured the cli, which I would love to find out/address)
It seems that our imports object here is missing imports defined from additionalProperties?
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 modules/openapi-generator/src/main/resources/typescript-angular/api.service.mustache, especially the imports object near line 33, and compare it with the generated src/api/default.service.ts in the linked reproduction. Run npm install followed by npm run build:additional; done means interfaces produced from additionalProperties are imported and the generated TypeScript builds successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, typescript
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100