open-api-spex / open_api_spex

Open API Specifications for Elixir Plug applications
Mozilla Public License 2.0
681 stars 177 forks source link

Response's content property spec seems reversed #614

Closed krainboltgreene closed 2 days ago

krainboltgreene commented 1 week ago

Here you can see the type annotation: https://github.com/open-api-spex/open_api_spex/blob/master/lib/open_api_spex/response.ex#L25

But the real type spec seems to be:

@type t :: %__MODULE__{
  description: String.t(),
  headers: %{String.t() => Header.t() | Reference.t()} | nil,
  content: %{MediaType.t() => String.t()} | nil,
  links: %{String.t() => Link.t() | Reference.t()} | nil,
  extensions: %{String.t() => any()} | nil
}

Based on https://swagger.io/specification/#responseObject:~:text=Response%20Object%20Examples

In fact all of the pairs seem inverted? Do yall want me to make a PR?

mbuhot commented 2 days ago

The type spec is correct. MediaType.t() is what the swagger spec refers to as Media Type Object and the String.t() map key is the media type, eg "text/plain".