ash_json_api icon indicating copy to clipboard operation
ash_json_api copied to clipboard

Add support for outputting OpenAPI spec in YAML format

Open col opened this issue 1 year ago • 2 comments

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

  • [ ] Bug fixes include regression tests
  • [ ] Features include unit/acceptance tests

col avatar Jun 18 '24 12:06 col

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.

zachdaniel avatar Jun 18 '24 12:06 zachdaniel

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

col avatar Jun 19 '24 04:06 col