OpenAPITools / OpenAPITools/openapi-generator
[BUG] [Typescript] Missing type
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?
- Have you searched for related issues/PRs?
Description
See examples below
openapi-generator version
From v4.3.0 to 5.0.0-SNAPSHOT
OpenAPI declaration file content or url
openapi: 3.0.0
info:
title: datasources-v2-frontend
version: 0.0.0
paths:
'/{id}':
patch:
parameters:
-
name: id
in: path
schema:
type: string
required: true
responses:
'200':
description: Ok
content:
application/json:
schema:
type: object
properties:
data: {type: object, properties: {}}
required:
- data
tags:
- Datasource
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Partial_WorkerDatasourceVersion__'
operationId: update-datasource
components:
schemas:
ApiOptions_:
type: object
properties:
oauth:
type: string
method:
oneOf:
-
type: string
enum:
- GET
-
type: string
enum:
- PATCH
-
type: string
enum:
- POST
-
type: string
enum:
- PUT
body:
type: string
headers:
type: object
properties: {}
additionalProperties:
type: string
query:
type: object
properties: {}
additionalProperties:
type: string
pagination:
oneOf:
-
type: object
properties:
type:
type: string
enum: [query]
value:
type: string
required:
- type
- value
-
type: object
properties:
type:
type: string
enum: [hypermediaAttribute]
value:
type: string
required:
- type
- value
ApiOptions:
$ref: '#/components/schemas/ApiOptions_'
Partial_WorkerDatasourceVersion__:
type: object
properties:
companyId:
type: string
resourceGroupIds:
type: array
items:
type: string
name:
type: string
apiOptions:
$ref: '#/components/schemas/ApiOptions'
Generation Details
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli:v4.3.0 generate \
--additional-properties=useSingleRequestParameter=true,enumPropertyNaming=UPPERCASE \
-i /local/swagger.yaml \
-g typescript-axios \
-o /local/client
Generated typescript:
/**
*
* @export
* @interface PartialWorkerDatasourceVersion
*/
export interface PartialWorkerDatasourceVersion {
/**
*
* @type {string}
* @memberof PartialWorkerDatasourceVersion
*/
companyId?: string;
/**
*
* @type {Array<string>}
* @memberof PartialWorkerDatasourceVersion
*/
resourceGroupIds?: Array<string>;
/**
*
* @type {string}
* @memberof PartialWorkerDatasourceVersion
*/
name?: string;
/**
*
* @type {ApiOptions}
* @memberof PartialWorkerDatasourceVersion
*/
apiOptions?: ApiOptions;
}
The type ApiOptions is never defined. Probably because the ApiOptions ref to ApiOptions with an underscore and the underscore gets removed by the generator leading to this bug.
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 supplied OpenAPI declaration and the docker command using the typescript-axios generator. Trace how the ApiOptions_ schema and its ApiOptions alias are named during generation; done means the generated TypeScript declares ApiOptions and the PartialWorkerDatasourceVersion reference resolves correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, 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