[BUG] [typescript-axios] Models not generated for multipart/form-data request
Bug Report Checklist
- [X] Have you provided a full/minimal spec to reproduce the issue?
- [X] Have you validated the input using an OpenAPI validator (example)?
- [X] Have you tested with the latest master to confirm the issue still exists?
- [X] Have you searched for related issues/PRs?
- [X] What's the actual output vs expected output?
- [ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
The typescript-axios (client) code generator does not generate model classes for multipart/form-data requests.
openapi-generator version
5.4.0
OpenAPI declaration file content or url
https://gist.github.com/cyberflohr/1961192f24060b9bbd05a649f5245c5f
Generation Details
npx openapi-generator-cli generate -g typescript-axios -i openapi.json -o .
Steps to reproduce
After the generation step, search the generated files for the desired model classes.
grep -e TemplateCreate -e AreaAttribute *
The grep command does not list any classes for TemplateCreate and AreaAttribute
api.ts: * @type {Array<AreaAttribute>}
api.ts: 'attributes': Array<AreaAttribute>;
openapi.json: "$ref": "#/components/schemas/TemplateCreate"
openapi.json: "AreaAttribute": {
openapi.json: "$ref": "#/components/schemas/AreaAttribute"
openapi.json: "TemplateCreate": {
Changing the request from "multipart/form-data" to "application/json" and re-generate the classes again will list the missing classes -> IMO a bug in combination with "multipart/form-data".
Related issues/PRs
Suggest a fix
any update on this? also encountering this issue for typescript-angular
Same here :thinking: The import + referenced file is correct but the file to import isn't generated. Is there any workaround?
seems to be a general issue with the generator https://github.com/OpenAPITools/openapi-generator/issues/12036
adding --global-property skipFormModel=false is a workaround but it's generating unused models as well :roll_eyes:
see https://github.com/OpenAPITools/openapi-generator/issues/10415#issuecomment-1003067496
If you are using openapitools.json to define the generator config, the new field needs to be added in the json. Example:
{
"$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json",
"spaces": 2,
"generator-cli": {
"version": "5.1.1",
"generators": {
"typescript-axios": {
"generatorName": "typescript-axios",
"inputSpec": "spec.json",
"output": "src/api/generated",
"typeMappings": {
"DateTime": "Date",
"Date": "Date"
},
// NEW FIELD
"globalProperty": {
"skipFormModel": false
}
}
}
}
}