REST endpoint returning rounded double numbers

  • 2 April 2020
  • 1 reply
  • 3 views

My swagger  schema is --

Ground_Level:        type: number        multipleOf: 1e-18

Actual Json reponse is -- "Ground_Level": 9.0999999999999996 . 
When I add this swagger json into K2 REST service instance, execute smartobject method - this value is getting rounded off and it returns - 9.1. 
I read OpenApi 2.0 specification  but could not find solution so that it returns me the exact full value not the round off value.

 

Also , in my schema I have another definition--

Geometry:    type: object    properties:      x:        type: number        #format: double        multipleOf: 1e-14      y:        type: number        #format: double        multipleOf: 1e-14

Actual Json Response -- 

"geometry": {
"x": 27620.710400000215,
"y": 38685.418400000781
}
This works perfectly fine in K2 REST instance and I get proper values.

I am unable to understand difference between behaviours of two definitions.
Can you please suggest if the rounding off numbers is an issue with K2 REST broker or there is something else which I should try in my swagger schema ?


1 reply

Badge +15

Hi,


 


Did you check what is the data type specified for that property in the SmartObject?


 

Reply