OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.94k stars 6.59k forks source link

[BUG][TypeScript] Bug Any Type is mapped to an object data type in TypeScript #20123

Open phalgunv opened 5 days ago

phalgunv commented 5 days ago

Bug Report Checklist

Description

As per Swagger documentation for Any Type

{} is shorthand syntax for an arbitrary-type schema

openapi-generator-cli maps shorthand for any type {} to objectdata type when language is set to typescript-angular

openapi-generator version

7.9.0 It is not a regression.

OpenAPI declaration file content or url

Swagger file: https://github.com/tmforum-apis/TMF620_ProductCatalog/blob/master/TMF620-ProductCatalog-v4.0.0.swagger.json

Please see excerpt for CharacteristicValueSpecification.value

                "value": {
                    "$ref": "#/definitions/Any",
                    "description": "A discrete value that the characteristic can take on, or the actual value of the characteristic"
                }
        "Any": {},
Generation Details

Language: typescript-angular

Steps to reproduce

openapi-generator-cli generate -i https://raw.githubusercontent.com/tmforum-apis/TMF620_ProductCatalog/refs/heads/master/TMF620-ProductCatalog-v4.0.0.swagger.json -g typescript-angular -o ./openapi-generator-cli-TMF620_generated-typescript-models

$ grep "value?" ./openapi-generator-cli-TMF620_generated-typescript-models/model/characteristicValueSpecification.ts
    value?: object;
Related issues/PRs
Suggest a fix

Below type could be used instead of object

  type AnyValue = string | number | boolean | any[] | { [key: string]: any };