# `JSONAPIPlug`
[🔗](https://github.com/lucacorti/jsonapi_plug/blob/main/lib/jsonapi_plug.ex#L1)

JSONAPIPlug context

This defines a struct for storing configuration and request data. `JSONAPIPlug.Plug` populates
its attributes by means of a number of other plug modules used to parse and validate requests
and stores it in the `Plug.Conn` private assings under the `jsonapi_plug` key.

# `case`

```elixir
@type case() :: :camelize | :dasherize | :underscore
```

String case

# `t`

```elixir
@type t() :: %JSONAPIPlug{
  allowed_includes: keyword(keyword()),
  base_url: String.t(),
  config: Keyword.t(),
  fields: term(),
  filter: term(),
  include: term(),
  page: term(),
  params: Plug.Conn.params(),
  resource: JSONAPIPlug.Resource.t(),
  sort: term()
}
```

JSONAPIPlug context

# `mime_type`

```elixir
@spec mime_type() :: String.t()
```

JSON:API MIME type

Returns the JSON:API MIME type.

# `recase`

```elixir
@spec recase(JSONAPIPlug.Resource.field_name() | String.t(), case()) :: String.t()
```

Recase resource fields

Changes the case of resource field names to the specified case, ignoring underscores
or dashes that are not between letters/numbers.

## Examples

    iex> recase("top_posts", :camelize)
    "topPosts"

    iex> recase(:top_posts, :camelize)
    "topPosts"

    iex> recase("_top_posts", :camelize)
    "_topPosts"

    iex> recase("_top__posts_", :camelize)
    "_top__posts_"

    iex> recase("", :camelize)
    ""

    iex> recase("top_posts", :dasherize)
    "top-posts"

    iex> recase("_top_posts", :dasherize)
    "_top-posts"

    iex> recase("_top__posts_", :dasherize)
    "_top__posts_"

    iex> recase("top-posts", :underscore)
    "top_posts"

    iex> recase(:top_posts, :underscore)
    "top_posts"

    iex> recase("-top-posts", :underscore)
    "-top_posts"

    iex> recase("-top--posts-", :underscore)
    "-top--posts-"

    iex> recase("corgiAge", :underscore)
    "corgi_age"

# `render`

```elixir
@spec render(
  Plug.Conn.t(),
  JSONAPIPlug.Resource.t() | [JSONAPIPlug.Resource.t()] | nil,
  JSONAPIPlug.Document.links() | nil,
  JSONAPIPlug.Document.meta() | nil,
  JSONAPIPlug.Resource.options()
) :: JSONAPIPlug.Document.t() | no_return()
```

Render JSON:API response

Renders the JSON:API response for the specified Resource.

# `url_for`

```elixir
@spec url_for(
  JSONAPIPlug.Resource.t() | [JSONAPIPlug.Resource.t()] | nil,
  Plug.Conn.t() | nil
) ::
  String.t()
```

Generates the resource link

Generates the resource link for a resource.

# `url_for_relationship`

```elixir
@spec url_for_relationship(
  JSONAPIPlug.Resource.t() | [JSONAPIPlug.Resource.t()],
  Plug.Conn.t() | nil,
  JSONAPIPlug.Document.ResourceObject.type()
) :: String.t()
```

Generate relationships link

Generates the relationships link for a resource.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
