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

Enum types are exposed as object in openapi spec #176

Closed olivermt closed 1 month ago

olivermt commented 1 month ago

Describe the bug

defmodule SomeType do
  use Ash.Type.Enum, values: [foo: "foo", bar: "bar"]
end

This ends up in openapi as:

{
        "additionalProp1": {}
      },

To Reproduce Just make any kind of enum, either with :atom, constrains: [one_of: [...]] or with the included Ash.Type.Enum sample

Expected behavior Be exposed as swagger enums: https://swagger.io/docs/specification/data-models/enums/

** Runtime

zachdaniel commented 1 month ago

I've made two changes: 1. it will now properly render enums since that was low hanging fruit, and 2. unknown types now properly show as "any" instead of "object".