OpenAPITools / OpenAPITools/openapi-generator
[BUG] NestJS - withInterfaces flag being ignored
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
My understanding of the NestJS OpenAPI Generator docs is that by not including the withInterfaces flag, I should expect models to instead be generated as classes.
Removing or setting this flag to false continues to output interfaces in typescript.
openapi-generator version
7.2
OpenAPI declaration file content or url
Generation Details
Language set to typescript-nestjs (by default this should set withInterfaces to false)
Steps to reproduce
Run npx @openapitools/openapi-generator-cli generate -i <location-of-openapi-spec> -g typescript-nestjs -o <your-output-dir>
Example OpenAPI spec
{
"openapi": "3.0.0",
"info": {
"title": "Dummy API",
"description": "Dummy",
"version": "0"
},
"paths": {},
"components": {
"schemas": {
"DummyClass": {
"type": "object",
"properties": {
"propertyOne": {
"type": "string"
},
"propertyTwo": {
"type": "string",
"format": "uuid"
}
},
"required": ["propertyOne", "propertyTwo"]
}
}
}
}
I would expect the file dummyClass.ts to have a class within it, but instead it has an interface.
I am aware that the nestjs generator is considered experimental, but I had thought I'd seen this working previously, though I can't confirm.
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 typescript-nestjs generator's handling of the withInterfaces option and reproduce the issue using the supplied minimal OpenAPI spec and npx command. Inspect the generated dummyClass.ts when the flag is omitted or false; done means it contains a class rather than an interface.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, typescript
- Domain
- api, backend, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100