# audience-defined

Source: https://apigenie.pl/docs/linter/asyncapi/rules/audience-defined

This rule checks whether the intended audience of an API is declared in the
`#/info/x-audience` extension of an AsyncAPI document.

## Rule Details

Knowing who an API is built for helps to decide how strict its review should
be, how carefully breaking changes must be handled, and where the API can be
published. AsyncAPI does not provide a field for this information.

The `audience-defined` rule fills this gap. It requires the `x-audience`
extension to be present in the info object, and its value to be one of the
following strings:

- `internal-team` - the API is used only by the team that owns it,
- `internal-company` - the API is used by other teams in the same company,
- `partner` - the API is shared with selected partners,
- `public` - the API is publicly available.

The rule reports `API audience (x-audience) is missing` when the extension
is absent, and `API audience (x-audience) has invalid value (...)` when its
value is not one of the strings listed above (including values that are not
strings at all).

## Configuration

None.

## Examples

**Good**. The audience of the API is clearly stated.

```yaml
asyncapi: 3.0.0
info:
  title: Pet Events
  version: 1.0.0
  x-audience: internal-company
```

**Bad**. The audience is not declared.

```yaml
asyncapi: 3.0.0
info:
  title: Pet Events
  version: 1.0.0
```

**Bad**. The audience has a value that is not recognized.

```yaml
asyncapi: 3.0.0
info:
  title: Pet Events
  version: 1.0.0
  x-audience: everyone
```

## When Not to Use It

You may disable this rule if your organization does not classify its APIs by
their audience.

## Compatibility

This rule is compatible with AsyncAPI 3.x documents. AsyncAPI 2.x documents
are rejected by the reader and are not linted.
