Liturgical-Calendar / LiturgicalCalendarAPI

A PHP script / API endpoint that will generate the Roman Catholic liturgical calendar for any given year, calculating the mobile festivities and the precedence of solemnities, feasts, memorials...
Apache License 2.0
39 stars 11 forks source link

allow *yaml* in ouput #211

Closed JohnRDOrazio closed 5 months ago

JohnRDOrazio commented 5 months ago

Currently, the API has a preference for JSON output, with some support for XML output and ICS output. However nowadays another popular data exchange format is YAML. We should enable a request for Content Type application/yaml.

This will require enabling the pecl extension yaml-emit on the server and implementing a minimum amount of logic to allow the transform on output.

JohnRDOrazio commented 5 months ago

first step taken, pecl package is now installed on the server!

JohnRDOrazio commented 5 months ago

apparently yaml_emit cannot directly handle PHP objects, only associative arrays (see php/pecl-file_formats-yaml issue #70). So unless that's ever a thing, we'll just have to json_decode(json_encode($output),true) to get an associative array, and then yaml_emit from there.

JohnRDOrazio commented 5 months ago

Implemented in commits c734a38eb69e635565a94460f15d6974f9ec126b...82bbf7cf8d416d39bbd642cdd31cfd4f2304ffea !

JohnRDOrazio commented 5 months ago

and added application/yaml to the OpenAPI schema in commit 82bbf7cf8d416d39bbd642cdd31cfd4f2304ffea...a359952c9f3c44a4dfb208b8288e6e8f31fde17c ! This issue is now complete!

JohnRDOrazio commented 5 months ago

yaml validation is now a thing too, in the litcal-tests interface! Implemented validation here in LitCalHealth and added the option in the tests interface.