ash-project / ash_json_api

The JSON:API extension for the Ash Framework
https://hexdocs.pm/ash_json_api
MIT License
55 stars 41 forks source link

Add support for outputting OpenAPI spec in YAML format #173

Closed col closed 3 days ago

col commented 1 month ago

Add an option to specify the format for the open api spec.

Usage:

use AshJsonApi.Router,
    domains: [Module.concat(["Helpdesk.Support"])],
    json_schema: "/json_schema",
    open_api: "/open_api",
    open_api_format: :yaml

Would require an additional dependency {:ymlr, "~> 2.0"}

Contributor checklist

zachdaniel commented 1 month ago

This is a great idea!

I think what we could do perhaps for the configuration is instead is something like

formats: [
  json: "/json",
  yaml: "/yaml"
]

Then, for each format, we serve the schema at that format at that route. The default would be

[json: "/"]

This avoids having to choose between one or the other.

Then, we'll make the yaml one error if Ymlr is not defined (if Code.ensure_loaded?(Ymlr), and explain in the docs that you need to add that dependency for it to work.

col commented 1 month ago

Happy to update the PR. Will find some time within the next week.