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: support RequestBody passed to operation macro #456

Merged

Conversation

Geekfish
Copy link
Contributor

@Geekfish Geekfish commented May 26, 2022

The operation macro currently supports passing arguments for url params, request body and response schemas in a "simplified" way (as tuples/keyword lists).

It also supports passing operation structs like %Parameter{} and %Response{}.

However, it didn't support passing %RequestBody{}, for example this:

operation :update
  summary: "Update user",
  request_body: %RequestBody{
    #...
  }
  # ...

would result in %Operation{requestBody: nil}.

This changeset fixes it so that we get the expected behaviour of
%Operation{requestBody: %RequestBody{}}.

Fixes: #457

The operation macro currently supports passing arguments for url params,
request body and response schemas in a "simplified" way (as
tuples/keyword lists).

It also supports passing operation structs like `%Parameter{}` and
`%Response{}`.

However it didn't support passing `%RequestBody{}`, for example this:

```elixir
operation :update
  summary: "Update user",,
  request_body: %RequestBody{
    #...
  }
  # ...
```

would result in `%Operation{requestBody: nil}`.

This changeset fixes it so that we get the expected behaviour of
`%Operation{requestBody: %RequestBody{}}`.
@Geekfish Geekfish force-pushed the fix/operation-explicit-structs branch from ce6d7c2 to b7cfe69 Compare May 26, 2022 18:58
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.

👍 Thanks @Geekfish

@mbuhot mbuhot merged commit 78e8946 into open-api-spex:master May 27, 2022
@Geekfish
Copy link
Contributor Author

Thanks for the lightning-fast review @mbuhot 🙌

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.

RequestBody not supported by operation macro
2 participants