OpenAPITools / OpenAPITools/openapi-generator
[BUG][Typescript] interface extends union type error ts(2312)
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
Trying to generate official docs of HERE Maps Routing API. Looks like the generator is trying to create an interface that extends a union type, which is not possible. Seeing the following error
src/__generated__/models/index.ts:4640:43 - error TS2312: An interface can only extend an object type or intersection of object types with statically known members.
4640 export interface TollSummaryTotal extends FarePrice {
Snippet of generated code
export type FarePrice = { type: 'range' } & RangePrice | { type: 'value' } & SinglePrice;
export interface TollSummaryTotal extends FarePrice {
}
openapi-generator version
6.6.0
OpenAPI declaration file content or url
https://developer.here.com/documentation/routing-api/swagger/v8.yaml
Generation Details
Using openapi-generator-cli version 2.7.0
openapi-generator-cli generate \
-g typescript-fetch \
-p "withoutRuntimeChecks=true,withInterfaces=true,enumNameSuffix=,supportsES6=true,enumPropertyNaming=original,modelPropertyNaming=original" \
Steps to reproduce
Related issues/PRs
Suggest a fix
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 by running the openapi-generator-cli typescript-fetch command against the linked HERE Maps Routing API specification, then inspect the generated src/generated/models/index.ts around TollSummaryTotal and FarePrice. Trace this output to the TypeScript generator and add coverage for the schema combination; done means generated TypeScript compiles without TS2312.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, typescript
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100