Lari Taskula <> changed:

           What    |Removed                     |Added
  Attachment #56247|0                           |1
        is obsolete|                            |

--- Comment #16 from Lari Taskula <> ---
Created attachment 56279
Bug 17008: Add "swaggerize" for Koha::Object and Koha::Objects

This patch adds new subroutine "swaggerize" for Koha::Object and Koha::Objects.

By matching column data types with corresponding Swagger data type, we can e.g.
numify values in order to be able to return borrowernumber:123 instead of

Before this patch, we usually returned an unblessed representation of the
Koha-object in controller by calling e.g.
  $c->$cb($patron->unblessed, 200);

This would cause the returned JSON to have { "borrowernumber": "123" ... }, or
in other words everything as strings (apart from undefs, which would be null).

Now, we also return an unblessed representation of the Koha-object, but where
numbers are actually numified simply by calling e.g.
  $c->$cb($patron->swaggerize, 200);

Here our returned JSON will have { "borrowernumber": 123 ... } in "integer"
type of Swagger, as well as every other column that is defined to be an
Decimals, doubles and floats should have "number" data type and will also be
numified for the returned JSON.

To test:
1. Apply this patch and run t/db_dependent/Koha/Util/Swagger.t
2. Apply REST of the patches and follow their test plan for seeing how this
   works in practice

You are receiving this mail because:
You are watching all bug changes.
Koha-bugs mailing list
website :
git :
bugs :

Reply via email to