You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to generate a model with a property that has the "any" type.
According to the OAS 3 spec, "Any Type" can be achieved by omitting the type property. See the section "Any Type" of https://swagger.io/docs/specification/data-models/data-types/
But typescript-fetch produces some unexpected results.
This behavior can be reproduced by modifying the Pet Store example on https://editor.swagger.io and generating the typescript-fetch client. The Pet Store example was converted to OAS 3 first.
For example:
Pet:
type: object
properties:
value:
description: any value
When generating the typescript-fetch client the result is the following:
export interface Pet {
/**
* any value
* @type {ModelObject}
* @memberof Pet
*/
value?: ModelObject;
}
The type ModelObject does not exist and the client can't be used that way.
After some tests I found out, that by adding additionalProperties, the result changes.
Adding additionalProperties: true results in:
export interface Pet {
/**
* any value
* @type {{ [key: string]: any; }}
* @memberof Pet
*/
value?: { [key: string]: any; };
}
Adding additionalProperties: false results in:
export interface Pet {
/**
* any value
* @type {any}
* @memberof Pet
*/
value?: any;
}
Please correct me if I am wrong, but I thought when additionalProperties is omitted, it is treated as if it was present with the value true.
Some additional info: Having a property with any type, the TSOA framework generates the following OAS:
"value": {
"additionalProperties": true
}
Suggestion: If the type is omitted, typescript-fetch should create a property of type any. additionalProperties shouldn't influence the output if no type is provided.
The text was updated successfully, but these errors were encountered:
I want to generate a model with a property that has the "any" type.
According to the OAS 3 spec, "Any Type" can be achieved by omitting the
type
property. See the section "Any Type" of https://swagger.io/docs/specification/data-models/data-types/But typescript-fetch produces some unexpected results.
This behavior can be reproduced by modifying the Pet Store example on https://editor.swagger.io and generating the typescript-fetch client. The Pet Store example was converted to OAS 3 first.
For example:
When generating the typescript-fetch client the result is the following:
The type ModelObject does not exist and the client can't be used that way.
After some tests I found out, that by adding
additionalProperties
, the result changes.Adding
additionalProperties: true
results in:Adding
additionalProperties: false
results in:Please correct me if I am wrong, but I thought when additionalProperties is omitted, it is treated as if it was present with the value
true
.Some additional info: Having a property with
any
type, the TSOA framework generates the following OAS:Suggestion: If the type is omitted, typescript-fetch should create a property of type
any
.additionalProperties
shouldn't influence the output if no type is provided.The text was updated successfully, but these errors were encountered: