Skip to content

Commit

Permalink
Document OpenApiSpex.Plug.NoneCache (#480)
Browse files Browse the repository at this point in the history
  • Loading branch information
zorbash authored Jul 25, 2022
1 parent 91a7162 commit dc3caf8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,13 @@ scope "/api" do
end
```

In development, to ensure the rendered spec is refreshed, you should disable caching with:

```elixir
# config/dev.exs
config :open_api_spex, :cache_adapter, OpenApiSpex.Plug.NoneCache
```

## Generating the Spec

You can write the swagger file to disk using the following Mix task and optionally, for your
Expand Down
11 changes: 6 additions & 5 deletions lib/open_api_spex/plug/cache.ex
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
defmodule OpenApiSpex.Plug.Cache do
@moduledoc """
Cache for OpenApiSpex
Cache for OpenApiSpex API specs.
Settings:
```elixir
config :open_api_spex, :cache_adapter, Module
```
There are already had three cache adapter:
There are three cache implementations:
* `OpenApiSpex.Plug.PersistentTermCache` - default
* `OpenApiSpex.Plug.AppEnvCache` - if VM not supported `persistent_term`
* `OpenApiSpex.Plug.AppEnvCache` - for VMs that don't support `persistent_term`
* `OpenApiSpex.Plug.NoneCache` - none cache
If you are constantly modifying specs during development, you can setting
like this in `dev.exs`:
If you are constantly modifying specs during development, you can configure the cache adapter
in `dev.exs` as follows to disable caching:
```elixir
config :open_api_spex, :cache_adapter, OpenApiSpex.Plug.NoneCache
Expand Down
11 changes: 10 additions & 1 deletion lib/open_api_spex/plug/none_cache.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
defmodule OpenApiSpex.Plug.NoneCache do
@moduledoc false
@moduledoc """
A cache adapter to disable caching. Intended to be used in development.
Configure it with:
```elixir
# config/dev.exs
config :open_api_spex, :cache_adapter, OpenApiSpex.Plug.NoneCache
```
"""

@behaviour OpenApiSpex.Plug.Cache

Expand Down

0 comments on commit dc3caf8

Please sign in to comment.