OpenAPITools / OpenAPITools/openapi-generator
[BUG][typescript-axios] Using the allOf description with a combination of $ref and an object results in a wrong typing
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
Using the typescript-axios generator fails to properly generate the client when using allOf with a combination of a $ref and an object.
openapi-generator version
5.1.0
OpenAPI declaration file content or url
swagger.yml:
openapi: 3.0.2
info:
title: hello
version: 1.0.0
components:
schemas:
SomeSchema:
type: object
properties:
some_prop:
type: integer
paths:
/foobar:
get:
responses:
'200':
description: ok
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/SomeSchema'
- type: object
properties:
foobar:
type: string
Generation Details
openapi-generator-cli generate -i http://localhost:8000/swagger.yml -g typescript-axios -o foo
Steps to reproduce
- Run the above script
- Look at the generated
api.ts - Notice that
foobarGetreturnsAxiosPromise<SomeSchema & object>
I would expect the return type to be AxiosPromise<SomeSchema & { foobar?: string }>
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
Run the stated openapi-generator-cli command against the provided swagger.yml and inspect the generated api.ts, focusing on the typescript-axios handling of the allOf response. Done means the generated foobarGet return type includes SomeSchema & { foobar?: string } rather than SomeSchema & object, while preserving the reproduction behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, typescript
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100