Closed sergioooo closed 1 year ago
You can submit a PR and I can work with you on getting a release out @sergioooo
I have not use mysql json type in an API before. What is the expected return format? Is it a string or an object?
I played around with this. CakePHP will return whatever type you have in the json column, which can be either object or array. Not exactly sure how to specify that correctly given this is essentially an adhoc field.
@sergioooo See if #511 works in your application. You should be able to test locally by modifying your composer.json with this:
"cnizzardini/cakephp-swagger-bake": "dev-issue/507-json-sql-type",
And then running
composer update cnizzardini/cakephp-swagger-bake
Man you are fast :D I just tested this and can confirm it works flawlessly. Thx! Great work!
ty np
In case a database table has a column with type json running bin/cake swagger bake will generate an error: [InvalidArgumentException] Schema type of
json
is invalid. Must be one of: array,boolean,integer,number,object,string, in /opt/repos/oc-be/vendor/cnizzardini/cakephp-swagger-bake/src/Lib/OpenApi/SchemaTrait.php on line 34Mapping json to object seems to do the trick: src/Lib/OpenApi/SchemaTrait.php: public function setType(string $type) { if($type == 'json') $type = OpenApiDataType::OBJECT; ....
What would be the proper way of achieving this without modifying the plugin source code?