Closed srchulo closed 5 years ago
I think this is caused by the “format” key in your specification. I’m not sure when I can find time to fix that, so I would suggest trying to remove the “format” for now.
How did you pretty print the JSON? I’m curious, in case the pretty printer might have changed something...
You can also look at the tests in https://github.com/jhthorsen/mojolicious-plugin-openapi/blob/master/t/v2-formats.t and maybe improve them.
So I removed "format", and still see the issue. I pretty printed it with Postman, but when I switch it to raw format, it still shows the quotes around the zero:
{"labels":["1\/23","1\/24","1\/25","1\/26","1\/27","1\/28","1\/29","1\/30","1\/31","2\/1","2\/2","2\/3","2\/4","2\/5","2\/6","2\/7","2\/8","2\/9","2\/10","2\/11","2\/12"],"last_period":[1456,1563,2194,578,0,"0",207,1531,2921,400,1977,2246,2353,3146,2348,2967,2965,1587,1716,1402,996],"this_period":[860,1929,1832,1772,2254,2131,1241,1378,1171,3260,1974,1519,3055,805,2724,1585,4992,3073,2037,2445,1979]}
And I actually see the same thing in the Chrome Network/Response tab:
{"labels":["1\/24","1\/25","1\/26","1\/27","1\/28","1\/29","1\/30","1\/31","2\/1","2\/2","2\/3","2\/4","2\/5","2\/6","2\/7","2\/8","2\/9","2\/10","2\/11","2\/12","2\/13"],"last_period":[1563,2194,578,0,"0",207,1531,2921,400,1977,2246,2353,3146,2348,2967,2965,1587,1716,1402,996,1718],"this_period":[1929,1832,1772,2254,2131,1241,1378,1171,3260,1974,1519,3055,805,2724,1585,4992,3073,2037,2445,2040,189]}
I'll try to take a look at the file and see if I can improve the tests, but that would still require updating the actual code, right?
I think so, but this is very surprising to me, since there’s a lot of tests for making sure a number is indeed a number.
Which versions of JSON::Validator and M::P::OpenAPI do you have? Are you sure you have the latest?
Related issue is https://github.com/mojolicious/json-validator/issues/147
I’m going to close this, since it’s a JV bug, and a new issue is opened.
Ah, thanks for figuring out what this was! I appreciate it :)
Here is my definition for an object that's returned by an API call:
Here is what the data structure looks like before passing it to openapi to render (printed using [p](https://metacpan.org/pod/Data::Printer#THE-p()-FUNCTION) from Data::Printer):
And here's what the JSON output is returned by openapi:
As you can see, the one
0
in thelast_period
array is a string for some reason, when everything else is a number. This isn't actually causing any issues for me client side, but I wanted to let you know since this seems like a bug. Please let me know if any other information from me would be helpful!