<div dir="ltr">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.<div><br></div><div>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):</div><div><br></div><div><div>+__PACKAGE__->add_columns(</div><div>+    "+code" => {</div><div>+        koha_description => "Unique key used to identify the attribute type"</div><div>+    },</div><div>+    "+description" =></div><div>+        { koha_description => "Description for the attribute type" },</div><div>+    "+repeatable" => {</div><div>+        koha_description =></div><div>+            "Defines if a patron can have multiple values for the attribute type"</div><div>+    },</div><div>+    "+unique_id" => {</div><div>+        koha_description => "Defines if the assinged value need to be unique"</div><div>+    },</div><div>+    "+opac_display" => {</div><div>+        koha_description =></div><div>+            "Defines if the attribute is visible to patrons on their account in the OPAC or not"</div><div>+    },</div><div>+    "+opac_editable" => {</div><div>+        koha_description =></div><div>+            "Defines if the attribute is editable by patrons on their account in the OPAC or not"</div><div>+    },</div><div>+    "+staff_searchable" => {</div><div>+        koha_description =></div><div>+            "Defines if the attribute is searchable via the patron search in the staff client"</div><div>+    },</div><div>+    "+authorised_value_category" => {</div><div>+        koha_description =></div><div>+            "Foreign key from authorised_values that links this attribute to an authorized value category"</div><div>+    },</div><div>+    "+display_checkout" => {</div><div>+        koha_description =></div><div>+            "Defines if the attribute  is displayed in checkout screens"</div><div>+    },</div><div>+    "+category_code" => {</div><div>+        koha_description =></div><div>+            "Defines a constraint on a patron category for the attribute type"</div><div>+    },</div><div>+    "+class" =></div><div>+        { koha_description => "Defines a class for grouping attributes" }</div><div>+);</div></div><div><br></div><div>This way we can have really simple access to those descriptions we already have in kohastructure.sql:</div><div><br></div><div><div>my $columns_info = Koha::Database->new->schema->resultset('BorrowerAttributeType')</div><div>    ->result_source->columns_info;</div></div><div><br></div><div>foreach $key ( keys %{ $columns_info } ) {</div><div>    print "Column: $key | Description: " . $columns_info->{$key}->{koha_description};</div><div>}</div><div><br></div><div>This could be an easy initial task for academy bugs.</div><div><br></div><div>Opinions? We will need this at some point if we would change our workflow and have DB structure handled by DBIC.</div><div><br></div><div>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!</div><div><br></div><div>Looking forward to your feedback!</div><div><br></div></div><div dir="ltr">-- <br></div><div data-smartmail="gmail_signature"><div dir="ltr"><div style="color:rgb(117,117,117);font-family:"helvetica neue",helvetica,arial,sans-serif;font-size:12.8px">Tomás Cohen Arazi</div><div style="color:rgb(117,117,117);font-family:"helvetica neue",helvetica,arial,sans-serif;font-size:12.8px">Theke Solutions (<a href="http://theke.io/">https://theke.io</a>)<br>✆ +54 9351 3513384<br>GPG: B2F3C15F</div></div></div>