OpenAPITools / OpenAPITools/openapi-generator
[BUG] typescript-axios generator ignores File schema
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
We have a model Attachment, which has a file property of type File.
Attachment:
type: object
properties:
file:
$ref: "#/components/schemas/File"
File:
type: object
properties:
dataUrl:
type: string
description: "Returns pre-signed, time-limited download URL"
readOnly: true
id:
type: string
format: uuid
mediaType:
type: string
description: Returns media type of the file
readOnly: true
Using the typescript-axios generator it ignores the File model and just adds any to the TS generated file.
export interface Attachment {
/**
*
* @type {any}
* @memberof Attachment
*/
'file'?: any;
}
But if I rename the File model to AttachmentFile it works and also generates a TS interface for it
export interface Attachment {
/**
*
* @type {AttachmentFile}
* @memberof Attachment
*/
'file'?: AttachmentFile;
}
export interface AttachmentFile {
/**
* Returns pre-signed, time-limited download URL
* @type {string}
* @memberof AttachmentFile
*/
'dataUrl'?: string;
/**
*
* @type {string}
* @memberof AttachmentFile
*/
'id'?: string;
/**
* Returns media type of the file
* @type {string}
* @memberof AttachmentFile
*/
'mediaType'?: string;
}
I would expect it to work even with the File model
openapi-generator version
"@openapitools/openapi-generator-cli": "^2.13.4"
Is it a bug or normal behaviour? We cannot just rename the File schema, it would be a breaking change, which we can't do right now.
Is there any other way around this?
Thanks 🙏
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 reproducing the provided OpenAPI schema with the typescript-axios generator and inspect the generated Attachment and File models. Trace how the typescript-axios generator resolves a schema named File, then add or update the relevant generator test if one is found. Done means the File schema produces a TypeScript interface and Attachment.file references it instead of any.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100