[Koha-bugs] [Bug 17008] REST API: Correct data types in Swagger

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Tue Nov 8 22:32:27 CET 2016


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17008

Josef Moravec <josef.moravec at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #56279|0                           |1
        is obsolete|                            |
  Attachment #56280|0                           |1
        is obsolete|                            |
  Attachment #56281|0                           |1
        is obsolete|                            |

--- Comment #20 from Josef Moravec <josef.moravec at gmail.com> ---
Created attachment 57352
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=57352&action=edit
[SIGNED-OFF] 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
borrowernumber:"123".

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"
data
type of Swagger, as well as every other column that is defined to be an
integer.
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

Signed-off-by: Josef Moravec <josef.moravec at gmail.com>

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list