<div dir="ltr"><div>It would be used like this:</div><div><br></div><div>kohadev-koha@kohadevbox:/home/vagrant/kohaclone$ ../misc4dev/<a href="http://koha_schema_to_swagger.pl">koha_schema_to_swagger.pl</a> --class BorrowerAttributeType | jq .</div><div>{</div><div>  "type": "object",</div><div>  "properties": {</div><div>    "code": {</div><div>      "type": [</div><div>        "string"</div><div>      ],</div><div>      "description": "Unique key used to identify the attribute type"</div><div>    },</div><div>    "description": {</div><div>      "type": [</div><div>        "string"</div><div>      ],</div><div>      "description": "Description for the attribute type"</div><div>    },</div><div>    "repeatable": {</div><div>      "type": [</div><div>        "boolean"</div><div>      ],</div><div>      "description": "Defines if a patron can have multiple values for the attribute type"</div><div>    },</div><div>    "unique_id": {</div><div>      "type": [</div><div>        "boolean"</div><div>      ],</div><div>      "description": "Defines if the assinged value need to be unique"</div><div>    },</div><div>    "opac_display": {</div><div>      "type": [</div><div>        "boolean"</div><div>      ],</div><div>      "description": "Defines if the attribute is visible to patrons on their account in the OPAC or not"</div><div>    },</div><div>    "opac_editable": {</div><div>      "type": [</div><div>        "boolean"</div><div>      ],</div><div>      "description": "Defines if the attribute is editable by patrons on their account in the OPAC or not"</div><div>    },</div><div>    "staff_searchable": {</div><div>      "type": [</div><div>        "boolean"</div><div>      ],</div><div>      "description": "Defines if the attribute is searchable via the patron search in the staff client"</div><div>    },</div><div>    "authorised_value_category": {</div><div>      "type": [</div><div>        "string",</div><div>        "null"</div><div>      ],</div><div>      "description": "Foreign key from authorised_values that links this attribute to an authorized value category"</div><div>    },</div><div>    "display_checkout": {</div><div>      "type": [</div><div>        "boolean"</div><div>      ],</div><div>      "description": "Defines if the attribute  is displayed in checkout screens"</div><div>    },</div><div>    "category_code": {</div><div>      "type": [</div><div>        "string",</div><div>        "null"</div><div>      ],</div><div>      "description": "Defines a constraint on a patron category for the attribute type"</div><div>    },</div><div>    "class": {</div><div>      "type": [</div><div>        "string"</div><div>      ],</div><div>      "description": "Defines a class for grouping attributes"</div><div>    }</div><div>  }</div><div>}</div></div><br><div class="gmail_quote"><div dir="ltr">El jue., 5 ene. 2017 a las 16:32, Tomas Cohen Arazi (<<a href="mailto:tomascohen@gmail.com">tomascohen@gmail.com</a>>) escribió:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg">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 class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">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 class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><div class="gmail_msg">+__PACKAGE__->add_columns(</div><div class="gmail_msg">+    "+code" => {</div><div class="gmail_msg">+        koha_description => "Unique key used to identify the attribute type"</div><div class="gmail_msg">+    },</div><div class="gmail_msg">+    "+description" =></div><div class="gmail_msg">+        { koha_description => "Description for the attribute type" },</div><div class="gmail_msg">+    "+repeatable" => {</div><div class="gmail_msg">+        koha_description =></div><div class="gmail_msg">+            "Defines if a patron can have multiple values for the attribute type"</div><div class="gmail_msg">+    },</div><div class="gmail_msg">+    "+unique_id" => {</div><div class="gmail_msg">+        koha_description => "Defines if the assinged value need to be unique"</div><div class="gmail_msg">+    },</div><div class="gmail_msg">+    "+opac_display" => {</div><div class="gmail_msg">+        koha_description =></div><div class="gmail_msg">+            "Defines if the attribute is visible to patrons on their account in the OPAC or not"</div><div class="gmail_msg">+    },</div><div class="gmail_msg">+    "+opac_editable" => {</div><div class="gmail_msg">+        koha_description =></div><div class="gmail_msg">+            "Defines if the attribute is editable by patrons on their account in the OPAC or not"</div><div class="gmail_msg">+    },</div><div class="gmail_msg">+    "+staff_searchable" => {</div><div class="gmail_msg">+        koha_description =></div><div class="gmail_msg">+            "Defines if the attribute is searchable via the patron search in the staff client"</div><div class="gmail_msg">+    },</div><div class="gmail_msg">+    "+authorised_value_category" => {</div><div class="gmail_msg">+        koha_description =></div><div class="gmail_msg">+            "Foreign key from authorised_values that links this attribute to an authorized value category"</div><div class="gmail_msg">+    },</div><div class="gmail_msg">+    "+display_checkout" => {</div><div class="gmail_msg">+        koha_description =></div><div class="gmail_msg">+            "Defines if the attribute  is displayed in checkout screens"</div><div class="gmail_msg">+    },</div><div class="gmail_msg">+    "+category_code" => {</div><div class="gmail_msg">+        koha_description =></div><div class="gmail_msg">+            "Defines a constraint on a patron category for the attribute type"</div><div class="gmail_msg">+    },</div><div class="gmail_msg">+    "+class" =></div><div class="gmail_msg">+        { koha_description => "Defines a class for grouping attributes" }</div><div class="gmail_msg">+);</div></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">This way we can have really simple access to those descriptions we already have in kohastructure.sql:</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><div class="gmail_msg">my $columns_info = Koha::Database->new->schema->resultset('BorrowerAttributeType')</div><div class="gmail_msg">    ->result_source->columns_info;</div></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">foreach $key ( keys %{ $columns_info } ) {</div><div class="gmail_msg">    print "Column: $key | Description: " . $columns_info->{$key}->{koha_description};</div><div class="gmail_msg">}</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">This could be an easy initial task for academy bugs.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Opinions? We will need this at some point if we would change our workflow and have DB structure handled by DBIC.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">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 class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Looking forward to your feedback!</div><div class="gmail_msg"><br class="gmail_msg"></div></div><div dir="ltr" class="gmail_msg">-- <br class="gmail_msg"></div><div data-smartmail="gmail_signature" class="gmail_msg"><div dir="ltr" class="gmail_msg"><div style="color:rgb(117,117,117);font-family:"helvetica neue",helvetica,arial,sans-serif;font-size:12.8px" class="gmail_msg">Tomás Cohen Arazi</div><div style="color:rgb(117,117,117);font-family:"helvetica neue",helvetica,arial,sans-serif;font-size:12.8px" class="gmail_msg">Theke Solutions (<a href="http://theke.io/" class="gmail_msg" target="_blank">https://theke.io</a>)<br class="gmail_msg">✆ <a href="tel:+54%209%20351%20351-3384" value="+5493513513384" class="gmail_msg" target="_blank">+54 9351 3513384</a><br class="gmail_msg">GPG: B2F3C15F</div></div></div></blockquote></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>