Upgrading code generator from 3.3.4 to 4.1.2 doesn't allow for any as a type.
This functionality seems to be broken since this PR: https://github.com/OpenAPITools/openapi-generator/pull/2453
While I understand the need for this change, it is an inconsistency in some environments, take for example a server in Spring, where Object can be anything but a primitive, and a client in TypeScript where object can only be { }, and not a string of number.
openapi: 3.0.0
info:
title: Test
description: Test
version: 0.0.0
servers:
- url: http://localhost:8080/api/
paths:
/example:
post:
operationId: filter example
requestBody:
description: One filter item
content:
application/json:
schema:
$ref: '#/components/schemas/FilterDTO'
responses:
"200":
description: "Success"
components:
schemas:
FilterDTO:
properties:
attribute:
type: string
value:
type: object
npx openapi-generator generate -i spec.yml -g typescript-angular -o output
Generate the code, and observe how value is of type object and not any.
I was using this in order to be able to pass any value to this field.
https://github.com/OpenAPITools/openapi-generator/pull/2453
What I suggest is to offer an option to generate a property of type any, maybe using a config option allowAny = true or something similar.
馃憤 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.
What about using --type-mappings to map "object" back to "any"?
e.g. --type-mappings object=any
Hi @wing328, thanks a lot for the quick reply, it seems to do the trick for me. Is this documented somewhere for future reference?
Please refer to https://openapi-generator.tech/docs/usage or the project's readme.
Most helpful comment
What about using --type-mappings to map "object" back to "any"?
e.g.
--type-mappings object=any