DEV Community

Discussion on: Creating REST APIs with Perl, Mojolicious and OpenAPI

Collapse
 
sbakker profile image
Steven Bakker

Question: your write that the OpenAPI spec can be written in YAML as well. While this is true according to the OpenAPI rules, the Mojolicious::Plugin::OpenAPI plugin only accepts JSON, AFAIK.
Or am I missing some hidden feature?

Collapse
 
raigaurav profile image
Gaurav Rai • Edited

Since you mentioned, I also tried to look at documentation of Mojolicious::Plugin::OpenAPI and I found only one reference of yaml. Also I haven't found any example of yaml. Maybe the documentation can be improved with some trivial example in .yaml format also.
I tried to use the yaml equivalent in my current code and its working. I have update it above. Mojolicious::Plugin::OpenAPI is internaly using YAML::XS and I have found it in this version.
It also internally use JSON::Validator which support following schema format.
So, yes the plugin support .yaml format file also.

Collapse
 
sbakker profile image
Steven Bakker • Edited

Yep, thanks. I just tried with another app I have. I recall trying before and the plugin was throwing errors. But I guess that was more due to the way I converted JSON to YAML. Syntax errors in a YAML spec are well-reported. Schema errors OTOH are much less clear in the YAML case.