openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[BUG] TS generator adds `http` tools imports generating ONLY models

Open andrescevp opened this issue 3 years ago • 1 comments

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?: Model classes without http tools imports
  • [ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

I am generating the TS only models, i get the models but wrong imports.

openapi-generator version

2.5.2 - Installed by yarn in WSL ubuntu 20.04 with openjdk 11.0.16 2022-07-19

OpenAPI declaration file content or url

Not relevante here

Generation Details

Only models are required.

TS_POST_PROCESS_FILE='prettier --write --config .prettierrc && eslint --fix' openapi-generator-cli generate -s -i http://0.0.0.0:8080/swagger.json --global-property models -g typescript -o ./src/@custom_types

... other imports import { HttpFile } from '../http/http';




##### Steps to reproduce

TS_POST_PROCESS_FILE='prettier --write --config .prettierrc && eslint --fix' openapi-generator-cli generate -s -i http://0.0.0.0:8080/swagger.json --global-property models -g typescript -o ./src/@custom_types


output:
```js
/**
 * Survey Integration Service API
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * OpenAPI spec version: v1
 * 
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

... other imports
import { HttpFile } from '../http/http';

The last import is wrong, do not exists.

Related issues/PRs
Suggest a fix

andrescevp avatar Sep 27 '22 08:09 andrescevp

Just wanted to post a workaround:

Download the typescript templates

openapi-generator-cli author template -g typescript -o ./templates/typescript

Modify the template Remove the HttpFile import from ./templates/typescript/model/model.mustache

Use the custom templates Use the custom templates by adding -t ./templates/typescript to your openapi-generator-cli command.

ctataryn avatar May 24 '24 13:05 ctataryn