[BUG] [typescript-axios] uniqueItem Sets in api spec generate wrong typescript
Created by: Persi
Description
When generating client classes with generator template typescript-axios having properties with type array and flag "uniqueItems: true", the generated typescript model classes cannot be compiled. This only happens if template parameter "withSeparateModelsAndApi" is set to true.
openapi-generator version
5.0.0-SNAPSHOT
OpenAPI declaration file content or url
openapi: 3.0.2
info:
title: Test API
description: This is a test
version: 0.0.1
contact:
name: Nobody
email: nobody@noway.com
paths:
/api/v1/test:
get:
operationId: getTest
responses:
"200":
description: OK
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/TestDTO"
components:
schemas:
TestDTO:
type: object
properties:
uniqueItemList:
uniqueItems: true
type: array
items:
type: integer
format: int64
itemList:
type: array
items:
type: integer
format: int64
servers:
- url: https://server.adress
description: Server
Actual output
// this import is wrong, Set is already a valid language primitive
import { Set } from './set';
/**
*
* @export
* @interface TestDTO
*/
export interface TestDTO {
/**
*
* @type {Set<number>}
* @memberof TestDTO
*/
uniqueItemList?: Set<number>;
/**
*
* @type {Array<number>}
* @memberof TestDTO
*/
itemList?: Array<number>;
}
Expected output
/**
*
* @export
* @interface TestDTO
*/
export interface TestDTO {
/**
*
* @type {Set<number>}
* @memberof TestDTO
*/
uniqueItemList?: Set<number>;
/**
*
* @type {Array<number>}
* @memberof TestDTO
*/
itemList?: Array<number>;
}
Command line used for generation
Used generator config:
{
"basePackage": "src",
"modelPackage": "src/model",
"apiPackage": "src/api",
"withSeparateModelsAndApi": true,
"withInterfaces": true,
"npmName": "test-api-client-typescript-axios",
"snapshot": true
}
Arguments: openapitools/openapi-generator-cli generate -i api-spec.yml -g typescript-axios -o out/generated/typescript-axios -c generator-config/config-typescript-axios.json
Steps to reproduce
- Create api-spec.yml from above example.
- Create config-typescript-axios.json from above example.
- Call openapi generator with above parameters.
Related issues/PRs
No related issues found.
Suggest a fix
Add type Set to list of typescript language primitives.