Skip to content

Conversation

moxley
Copy link
Contributor

@moxley moxley commented May 4, 2020

Fix #1

More informative exception when docs are missing for controller action

Before:

** (MatchError) no match of right hand side value: nil

After:

[warn] No docs found for function Elixir.SppWeb.Api.MessageController.indexb/2

Fix #2

Allow response spec to have 4th "opts" argument

The shape of a response in the @doc responses: keyword-list/map was:

{http_status, {description, mime_type, schema}}

A fourth element of the inner tuple was previously accepted (maybe it ignored?), but a recent
revision of OpenApiSpex made it a raised exception:

** (FunctionClauseError) no function clause matching in anonymous fn/1 in OpenApiSpex.Controller.build_responses/1

This commit change passes an optional fourth element to the opts argument of Operation.response/4.

moxley added 2 commits May 3, 2020 17:33
Before:
```
** (MatchError) no match of right hand side value: nil
```

After:
```
** (RuntimeError) No docs found for function Elixir.SppWeb.Api.MessageController.indexb/2
```
The shape of a response in the `@doc responses:` keyword-list/map was:

```elixir
{http_status, {description, mime_type, schema}}
```

A fourth element of the inner tuple was previously accepted (maybe it ignored?), but a recent
revision of OpenApiSpex made it a raised exception:

```
** (FunctionClauseError) no function clause matching in anonymous fn/1 in OpenApiSpex.Controller.build_responses/1
```

This commit change passes an optional forth element to the `opts` argument of `Operation.response/4`.
Copy link
Collaborator

@mbuhot mbuhot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 👍

@mbuhot
Copy link
Collaborator

mbuhot commented May 4, 2020

Looks like a dialyzer error coming from

@spec __api_operation__(module(), atom()) :: Operation.t() | nil

now that get_docs raises rather than returning :error, the | nil code path is unreachable.

@moxley moxley force-pushed the doc_based_specs_fixes branch from d2ce695 to 2755daf Compare May 8, 2020 16:39
@moxley moxley force-pushed the doc_based_specs_fixes branch from 2755daf to 2aa1641 Compare May 11, 2020 19:47
@moxley moxley merged commit e4eca23 into open-api-spex:master May 11, 2020
@moxley moxley deleted the doc_based_specs_fixes branch May 11, 2020 19:50
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.

3 participants