OpenAPITools / OpenAPITools/openapi-generator
[BUG] [typescript-redux-query] index.ts overwrites file generated from type named Index
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)?
- What's the version of OpenAPI Generator used?
- Have you search for related issues/PRs?
- What's the actual output vs expected output?
Description
If I have a type named Index, the generated index.ts overwrites Index.ts generated from the type.
openapi-generator version
4.3.0
OpenAPI declaration file content or url
openapi: '3.0.0'
info:
version: 0.0.0
title: Bug
paths:
/bug:
get:
responses:
default:
$ref: '#/components/responses/Response'
components:
responses:
Response:
description: response
content:
application/json:
schema:
$ref: '#/components/schemas/Index'
schemas:
Index:
type: string
enum:
- foo
- bar
Command line used for generation
openapi-generator generate -i bug.yaml -g typescript-redux-query -o bug/
Steps to reproduce
- Generate code with the above command line
- Check the generated code with
tsc bug/src/index.ts - You get
bug/src/apis/DefaultApi.ts:19:5 - error TS2305: Module '"../../../../../../Users/thsoft/Temp/bug/src/models"' has no exported member 'Index'.
19 Index,
~~~~~
because models/Index.ts was overwritten by models/index.ts.
Related issues/PRs
I found none.
Suggest a fix
There could be two alternatives:
- Rename
models/Index.tssince the file name is arbitrary. - Generate no
index.tssince it is just a convention (maybe could be disabled by a generator option).
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
Reproduce the issue with the provided OpenAPI declaration and the typescript-redux-query command, then inspect how generated models/Index.ts and models/index.ts are produced. Verify the fix by running tsc bug/src/index.ts and confirming the generated Index export is preserved without overwriting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, typescript
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100