Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow empty content for Response #453

Conversation

MichalDolata
Copy link
Contributor

#451 introduced a change that doesn't meet OpenAPI specification. https://spec.openapis.org/oas/v3.1.0#fixed-fields-14 - content can be empty.

The mentioned change caused errors in following example

  operation(:operation,
    summary: "summary",
    description: "description",
    request_body: {nil, "application/json", SchemaRequest},
    responses: %{
      201 => {"Operation succeed", nil, nil}
    }
  )
** (RuntimeError) Expected string or map for request_body: nil
    (open_api_spex 3.11.0) lib/open_api_spex/operation.ex:320: OpenApiSpex.Operation.build_content_map/2
    (open_api_spex 3.11.0) lib/open_api_spex/operation.ex:161: OpenApiSpex.Operation.response/4
    (open_api_spex 3.11.0) lib/open_api_spex/operation_builder.ex:82: anonymous fn/1 in OpenApiSpex.OperationBuilder.build_responses/1
    (elixir 1.13.1) lib/enum.ex:1597: anonymous fn/3 in Enum.map/2
    (stdlib 3.17) maps.erl:410: :maps.fold_1/3
    (elixir 1.13.1) lib/enum.ex:2408: Enum.map/2
    (elixir 1.13.1) lib/map.ex:219: Map.new/2
    (open_api_spex 3.11.0) lib/open_api_spex/controller_specs.ex:393: OpenApiSpex.ControllerSpecs.operation_spec/3
    ...: (module)

This PR allows back to define empty response content

@moxley
Copy link
Contributor

moxley commented May 20, 2022

Nice catch @MichalDolata! Looks good. Thank you!!!

@moxley moxley merged commit fa684e9 into open-api-spex:master May 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants