OpenAPITools / OpenAPITools/openapi-generator
[BUG] typescript-axios generates response names
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)?
- Have you tested with the latest master to confirm the issue still exists?
- I didn't do this because the command mvnw doesn't exist on my machine, and I didn't look further into why that is (sorry)
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
Description
When running the OpenAPI CLI Generator with typescript-axios, it appears my response names get assigned a name, and I can't figure out how to set a name for the interface/file that gets generated. I was expecting it to be the property's name, like it usually is for other components.
e.g. in the spec listed below
expected: generated/models/ResponseModel.ts with an exported interface named ResponseModel
actual: generated/models/me-get200-response-inner.ts with an exported interface named MeGet200ResponseInner
openapi-generator version
- package @openapitools/openapi-generator-cli ^2.6.0
- openapitools.json generator-cli 6.6.0
OpenAPI declaration file content or url
openapi.yml
openapi: 3.0.3
info:
version: 0.1.0
title: API Reference
description: API Endpoints for application
tags:
- name: me
paths:
/me:
get:
tags:
- me
description: Returns me data
operationId: me-get
responses:
'200':
$ref: '#/components/responses/ResponseModel'
components:
responses:
ResponseModel:
description: OK
content:
application/json:
schema:
type: array
items:
type: object
properties:
username:
type: string
date:
type: number
openapitools.json
{
"$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json",
"spaces": 2,
"generator-cli": {
"version": "6.6.0",
"useDocker": true
}
}
Generation Details
Flags that I use:
- -g typescript-axios
- -i local/openapi.yml
- -o local/generated/
- -p withSeparateModelsAndApi=true,apiPackage=api,modelPackage=models,supportsES6=true,withInterfaces=true
Steps to reproduce
mkdir openapi-response-namecd openapi-response-namenpm initnpm i @openapitools/openapi-generator-cli axiosnpm i -D typescript- copy openapi.yml contents above to
openapi.ymlfile - copy openapitools.json contents above to
openapitools.jsonfile - Run
npx openapi-generator-cli generate -g typescript-axios -i local/openapi.yml -o local/generated/ -p withSeparateModelsAndApi=true,apiPackage=api,modelPackage=models,supportsES6=true,withInterfaces=true
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 openapi.yml and openapitools.json using the listed typescript-axios command. Compare generated/models/me-get200-response-inner.ts with the components/responses/ResponseModel reference, then trace the generator's response-model naming path. Done means the generated model file and exported interface use the intended ResponseModel name.
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
- 45/100