AnyType is not defined in typescript generated code.
In some situations, schemas return any, this is handled in other languages where that is translated into something the language understands, examples:
Java: ObjectC#: `ObjectRust: serde_json:ValueHowever, this translation is not made for typescript, and the generators write AnyType in such situations, leading to type errors:
Cannot find name 'AnyType'

5.0.0-SNAPSHOT
The part that is causing troubles look like this:
"cat": {
"allOf": [
{
"$ref": "#/components/schemas/Cat"
},
{
"description": "Cat information"
}
]
This was generated using @nestjs/swagger and the problem is that the generator is unable to understand the second part and that one ends in _AnyType_
This is a full example:
openapi: 3.0.1
info:
version: 1.0.0
title: Example
license:
name: MIT
servers:
- url: http://api.example.xyz/v1
paths:
/person/display/{personId}:
get:
parameters:
- name: personId
in: path
required: true
description: The id of the person to retrieve
schema:
type: string
operationId: list
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/Person"
components:
schemas:
Person:
type: object
discriminator:
propertyName: $_type
mapping:
a: '#/components/schemas/Adult'
c: Child
properties:
$_type:
type: string
lastName:
type: string
firstName:
type: string
Adult:
description: A representation of an adult
allOf:
- $ref: '#/components/schemas/Person'
- type: object
properties:
children:
type: array
items:
$ref: "#/components/schemas/Child"
firstChild:
allOf:
- $ref: '#/components/schemas/Person'
- description: First child
Child:
description: A representation of a child
allOf:
- type: object
properties:
age:
type: integer
format: int32
- $ref: '#/components/schemas/Person'
output using typescript-axios
/**
* A representation of an adult
* @export
* @interface Adult
*/
export interface Adult extends Person {
/**
*
* @type {Array<Child>}
* @memberof Adult
*/
children?: Array<Child>;
/**
*
* @type {Person & AnyType}
* @memberof Adult
*/
firstChild?: Person & AnyType;
}
/**
NOTE: AnyType is not defined anywhere.
The proposal is simple, adding a translation for AnyType -> object for all the typescript generators. This can be achieved adding one line to AbstractTypeScriptCodegen.java like the ones we have in other generators:
typeMapping.put("AnyType", "Object");
馃憤 Thanks for opening this issue!
馃彿 I have applied any labels matching special text in your issue.
The team will review the labels and make any necessary changes.
FYI, I'm working on a fix for this, so I'll present a PR that fixes this situation
If the fix already present in the published version? I cannot see any versions after 4.3.1, which has the bug.
@krajek I think it was published only in v5, which I think it's still in beta!

@krajek @codeserk I ran into the same issue while using the latest stable 4.3.1 but updating to 5.0.0-beta2 resolved the issue. Thanks for the suggestion!
If you're able to; try downgrading to 4.3.0
This resolved the issue for me while I came from 4.1.3. AnyType became Object again.
openapitools/openapi-generator-cli:v4.2.3 works for me
The latest master has this issue resolved. Please try the SNAPSHOT version (mentioned in the README) and let us know if you've any feedback before the official release of v5.0.0 in Dec 2020.
please can someone explain the fix.i have many problems in openapi like:
-basepath="http://localhost".
-Anytype bug.
Most helpful comment
If you're able to; try downgrading to
4.3.0This resolved the issue for me while I came from
4.1.3.AnyTypebecameObjectagain.