openapi-client-axios icon indicating copy to clipboard operation
openapi-client-axios copied to clipboard

Wrong typing for object

Open meabed opened this issue 2 years ago • 7 comments

The typing for "object" is wrong in latest release. The key could be string | number or anything. This has been changed in latest release. image

meabed avatar Nov 09 '21 06:11 meabed

@meabed can you be more specific?

Is this related to the openapi-client-axios-typegen package?

anttiviljami avatar Nov 09 '21 11:11 anttiviljami

Thanks @anttiviljami, yes it's the typegen package.

meabed avatar Nov 09 '21 12:11 meabed

Can you clarify?

What exactly changed? What is the desired/expected behaviour?

anttiviljami avatar Nov 09 '21 12:11 anttiviljami

Sure, The previous behavior is swagger with property "object", for example:

"properties": {
  "metadata": {
    "description": "",
    "type": "object"
  }
}

it generate typing

metadata?: {}

After the last update, it generates types as:

  metadata?: {
      [key: string]: any;
  };

Which is wrong because key could be number / undefined / null / string. I think it might be an issue with dtsgenerator?

Thanks!

meabed avatar Nov 09 '21 14:11 meabed

Hey there,

you should report this error on https://github.com/horiuchi/dtsgenerator (used by : https://github.com/anttiviljami/dtsgenerator)

lmarvaud avatar Nov 24 '21 10:11 lmarvaud

This is an upstream issue with dtsgenerator but I’ll leave this open for the time being to track

anttiviljami avatar Mar 11 '23 07:03 anttiviljami

did someone report this already? / any updates?

in my case this happens, when defining: oneOf: [{ type: 'string' }, { type: 'number' }]

paulwer avatar Apr 04 '23 07:04 paulwer