SkeLLLa / fastify-oas

Fastify OpenAPI plugin.
https://www.comebackalive.in.ua/
MIT License
72 stars 20 forks source link

JS object serialisation issue #50

Closed fyang1024 closed 4 years ago

fyang1024 commented 4 years ago

I've defined an object property in response schema as below:

taxes: {
   type: 'string',
   additionalProperties: {
      type: 'number'
   }
}

The JS object property value in response data is like

taxes: { stampDuty: 0.12 }

Expected data in response:

"taxes": {
   "stampDuty": 0.12
}

Actual data in response:

"taxes": "[object Object]"
SkeLLLa commented 4 years ago

That's expected behavior, since you've defined taxes as string and pass an object. So object is serialized to string. If you need an object, you should pass proper type to taxes.