OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.67k stars 6.54k forks source link

[BUG] axios typescript generator generate models in a single file #11060

Open albertotn opened 2 years ago

albertotn commented 2 years ago

Bug Report Checklist

Description

Using axios typescript generator model defined in openApi are created in the same file as interfaces

openapi-generator version

5.3.0

OpenAPI declaration file content or url

see https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v2.0/yaml/petstore.yaml

Generation Details
  1. java in the path
Steps to reproduce
  1. download in a folder https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v2.0/yaml/petstore.yaml
  2. run java -jar openapi-generator-cli-5.3.0.jar generate -i petstore.yaml -g typescript-axios -o generatedPetStore
  3. generated models are inside the api file, instead should be in a separated file
Related issues/PRs
Suggest a fix

Like java spring generator, each model should be in a separated file ( as future reference for search split / splitted / multiple )

amelnikoff commented 2 years ago

Have you tried to use additionalProperty: withSeparateModelsAndApi ?

DOrlov77 commented 2 years ago

Using withSeparateModelsAndApi lead to the generator failure.

DOrlov77 commented 2 years ago

I found the solution, the apiPackage and modelPackage params must be defined together with the withSeparateModelsAndApi, like: { "withSeparateModelsAndApi": true, "apiPackage": "apis", "modelPackage": "models" }