[Koha-devel] DBIC > Swagger object definition

Kyle Hall kyle.m.hall at gmail.com
Fri Jan 6 16:51:40 CET 2017


That sounds like a nice idea! I'd love to hear what Jonathan thinks!

Kyle

<https://secure2.convio.net/cffh/site/Donation2?df_id=1395&FR_ID=4715&PROXY_ID=2706639&PROXY_TYPE=20&1395.donation=form1&s_src=CHORUS&s_subsrc=CHAADOEB>

http://www.kylehall.info
ByWater Solutions ( http://bywatersolutions.com )
Meadville Public Library ( http://www.meadvillelibrary.org )
Crawford County Federated Library System ( http://www.ccfls.org )

On Thu, Jan 5, 2017 at 2:32 PM, Tomas Cohen Arazi <tomascohen at gmail.com>
wrote:

> In the process of writing a script for generating swagger object
> definitions our of DBIC schemas (for sort-of scaffolding them making easier
> to add REST endpoints) I resumed some talks we had at Marseille, and also
> picked some previous work from Lari on automating the Koha::Object <->
> Swagger translation.
>
> One thing that would be handy for this process, is to add the column
> descriptions to the schema files. This can be accomplished like this
> example (for Koha::Schema::Result::BorrowerAttributeType):
>
> +__PACKAGE__->add_columns(
> +    "+code" => {
> +        koha_description => "Unique key used to identify the attribute
> type"
> +    },
> +    "+description" =>
> +        { koha_description => "Description for the attribute type" },
> +    "+repeatable" => {
> +        koha_description =>
> +            "Defines if a patron can have multiple values for the
> attribute type"
> +    },
> +    "+unique_id" => {
> +        koha_description => "Defines if the assinged value need to be
> unique"
> +    },
> +    "+opac_display" => {
> +        koha_description =>
> +            "Defines if the attribute is visible to patrons on their
> account in the OPAC or not"
> +    },
> +    "+opac_editable" => {
> +        koha_description =>
> +            "Defines if the attribute is editable by patrons on their
> account in the OPAC or not"
> +    },
> +    "+staff_searchable" => {
> +        koha_description =>
> +            "Defines if the attribute is searchable via the patron search
> in the staff client"
> +    },
> +    "+authorised_value_category" => {
> +        koha_description =>
> +            "Foreign key from authorised_values that links this attribute
> to an authorized value category"
> +    },
> +    "+display_checkout" => {
> +        koha_description =>
> +            "Defines if the attribute  is displayed in checkout screens"
> +    },
> +    "+category_code" => {
> +        koha_description =>
> +            "Defines a constraint on a patron category for the attribute
> type"
> +    },
> +    "+class" =>
> +        { koha_description => "Defines a class for grouping attributes" }
> +);
>
> This way we can have really simple access to those descriptions we already
> have in kohastructure.sql:
>
> my $columns_info = Koha::Database->new->schema->resultset('
> BorrowerAttributeType')
>     ->result_source->columns_info;
>
> foreach $key ( keys %{ $columns_info } ) {
>     print "Column: $key | Description: " . $columns_info->{$key}->{koha_
> description};
> }
>
> This could be an easy initial task for academy bugs.
>
> Opinions? We will need this at some point if we would change our workflow
> and have DB structure handled by DBIC.
>
> Anyway, I'll send a pull request to Jonathan so he adds this handy (and
> perfectible) script to his koha-misc4dev repository. This will make it
> available on kohadevbox right out-of-the-box. I'll then try to document it
> on Kyle's Koha Developer Handbook, which we all should add our bits of
> knowledge!
>
> Looking forward to your feedback!
>
> --
> Tomás Cohen Arazi
> Theke Solutions (https://theke.io <http://theke.io/>)
> ✆ +54 9351 3513384 <+54%209%20351%20351-3384>
> GPG: B2F3C15F
>
> _______________________________________________
> Koha-devel mailing list
> Koha-devel at lists.koha-community.org
> http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
> website : http://www.koha-community.org/
> git : http://git.koha-community.org/
> bugs : http://bugs.koha-community.org/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.koha-community.org/pipermail/koha-devel/attachments/20170106/5c5db51a/attachment-0001.html>


More information about the Koha-devel mailing list