OpenAPITools / OpenAPITools/openapi-generator

[BUG] typescript-axios doesn't export models when withSeparateModelsAndApi flag is true

Open
#6,423 2 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
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?
  • [N/A] Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
    5.0.0-SNAPSHOT
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

I'm using the typescript-axios generator with the withSeparateModelsAndApi flag:

withSeparateModelsAndApi: true
apiPackage: 'api'
modelPackage: 'model'

Basically, when using this, the models aren't exported from the root package:

// index.d.ts
export * from "./api";
export * from "./configuration";

However both the API classes and models are correctly included with the default setup which uses a single file for everything. It would be desirable to export the models in all cases. The separate-file structure is much nicer for editors that are slow processing large files.

openapi-generator version

5.0.0-SNAPSHOT

OpenAPI declaration file content or url

See above

Command line used for generation
Steps to reproduce
Related issues/PRs
Suggest a fix

Just export the modelPackage directory as well, don't think it's super complicated.

ETA: Apologies for not editing the description when I first posted this.

ETA Again: withSeparateModelsAndApi: true - I accidentally included false before because that was the config I was debugging with. Sorry for being sloppy today!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the typescript-axios generator and inspect how it creates index.d.ts when withSeparateModelsAndApi is true, using the apiPackage and modelPackage settings shown. Done means the generated root package exports both the API classes and the models; verify the generated output against the single-file setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.