OpenAPITools / OpenAPITools/openapi-generator

Generator for typescript-axios generates primitive types (string, number, etc) and array/list as any

Open
#16,442 8 comments 0 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?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

The types generated by the generator, generates string, int, and other types that qualify as primitives, together with list or array types in the target language (typescript/axios) as any rather than their corresponsding types. Enums are also generated as empty interfaces

openapi-generator version

6.6.0, 7.0.0

OpenAPI declaration file content or url

https://gist.github.com/calebpitan/9f988e14b0b567bc54ee6043d1f1dfe2

Generation Details

Script

#!/usr/bin/env bash

openapi-generator-cli generate --skip-validate-spec\
  -i http://localhost:3780/openapi.json\
  -g typescript-axios\
  -o client\
  -p useSingleRequestParameter=true,supportsES6=true,ensureUniqueParams=true\
  -c ./openapi-gen.config.yml\
  -t ./client/templates

Config (openapi-gen.config.yml)

additionalProperties:
  ensureUniqueParams: true
  supportsES6: true
  useSingleRequestParameter: true
  enumPropertyNaming: UPPERCASE
  stringEnums: true
  withoutPrefixEnums: false
globalProperties:
  apiDocs: true
  modelDocs: true
Steps to reproduce
  • Create the config file with the contents above in the cwd as the script
  • Run the script provided above on the schema uploaded to the GH Gist linked above
  • Open the client folder where the artifacts are generated and check the api.ts file for type defs
Related issues/PRs

None

Suggest a fix

None

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

Reproduce the issue with the provided CLI script, configuration, and OpenAPI schema, then inspect the generated client/api.ts output and the typescript-axios generator templates. Done means primitive and array types map to their corresponding TypeScript types and enums are generated with their members rather than as empty interfaces.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, typescript
Domain
api, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.