Skip to content

Commit

Permalink
more usage notes in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ityonemo committed Sep 19, 2023
1 parent befd72d commit efd0721
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,31 @@ defmodule MyProjectWeb.ApiRouter do
end
```

### Embedding inside of an existing router

You may also embed apical inside of an existing phoenix router:

```elixir
scope "/api", MyProjectWeb.Api do
require Apical

Apical.router_from_file("priv/assets/api/openapi.v1.yaml",
controller: MyProjectWeb.ApiController)
end
```

If you are embedding Apical in an existing router, be sure to delete
the following lines from the phoenix *endpoint*:

```elixir
plug Plug.Parsers,
parsers: [:urlencoded, :multipart, :json],
pass: ["*/*"],
json_decoder: Phoenix.json_library()
```

As Apical will do its own parsing.

## Using it in tests:

If you're using OpenAPI as a client, you can use Apical to test that your
Expand Down

0 comments on commit efd0721

Please sign in to comment.