Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #6929
Closed
Open
Issue created Jul 14, 2020 by Administrator@rootContributor

[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
  1. Create api-spec.yml from above example.
  2. Create config-typescript-axios.json from above example.
  3. 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.

Assignee
Assign to
Time tracking