OpenAPITools / OpenAPITools/openapi-generator
[BUG] [Typescript Angular] generates invalid project when there are no models
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)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
When generating an api that has no models the typescript-angular generator will generate an empty models.ts file which is then imported in index.ts. This causes a compile error when building the client
'model/models.ts' is not a module.
openapi-generator version
6.2.0
OpenAPI declaration file content or url
openapi: 3.0.1
info:
title: 'Demo'
version: '1.0'
paths:
/doit:
get:
tags:
- Tag
operationId: doSomething
responses:
'204':
description: No Content
components: { }
Generation Details
{
"$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json",
"spaces": 2,
"generator-cli": {
"version": "6.2.0",
"generators": {
"ng-client": {
"generatorName": "typescript-angular",
"glob": "swagger.yaml",
"output": "#{cwd}/dist",
"additionalProperties": {
"npmName": "test-client",
"npmVersion": "0.0.1",
"npmRepository": "https://npm.pkg.github.com",
"providedIn": "root"
}
}
}
}
}
Steps to reproduce
generate the typescript project and then attempt to compile it
Related issues/PRs
Suggest a fix
model.ts should only be generated and imported if there are models
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
Generate the supplied OpenAPI declaration with the typescript-angular generator, then compile the generated client to reproduce the invalid models.ts import from index.ts. Inspect how model files and the index export are generated for specs with no components.models. Done means the no-model client compiles without an empty models.ts module or an invalid import.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, typescript
- Domain
- frontend, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100