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
Types generated by platformatic client of a Record<string, array> gives an generic object as result. "additionalProperties" are omited of OpenAPI specs
#2353
Hi. Im facing some problems trying to generate the api-types.d.ts of a Record<string, array> response. But the client always generate an empty "object" as result. Im using "platformatic": "^1.32.0",
I was trying to debug and found where was the problem. I tried some workaround and it generates the types as I expected but maybe the code that I implemented needs some tweaks:
// File: @platformatic>client-cli>lib>get-type.mjs>getType// Line of code: 74if(typeDef.type==='object'){if(!typeDef.properties||Object.keys(typeDef.properties).length===0){//===>START of the workaroundif(typeDef.additionalProperties){return`{ [key: string]: ${getType(typeDef.additionalProperties,methodType,spec)} }`}//<===END of the workaround// Object without propertiesreturn'object'}letoutput='{ '// TODO: add a test for objects without properties/* c8 ignore next 1 */constprops=Object.keys(typeDef.properties||{}).map((prop)=>{letrequired=falseif(typeDef.required){required=!!typeDef.required.includes(prop)}return`'${prop}'${required ? '' : '?'}: ${getType(typeDef.properties[prop],methodType,spec)}`})
Hi. Im facing some problems trying to generate the api-types.d.ts of a Record<string, array> response. But the client always generate an empty "object" as result. Im using "platformatic": "^1.32.0",
Given this pseudo-schema:
I was trying to debug and found where was the problem. I tried some workaround and it generates the types as I expected but maybe the code that I implemented needs some tweaks:
platformatic/packages/client-cli/lib/get-type.mjs
Line 74 in 954577f
Generated types without applying the workaround:
After the workaround:
The text was updated successfully, but these errors were encountered: