# json-api/content-type

Source: https://apigenie.pl/docs/linter/openapi/rules/json-api-content-type

This rule ensures that every request and response in an OpenAPI schema provides
the `application/vnd.api+json` media type.

## Rule Details

The `json-api/content-type` rule is designed to ensure that every request and
response in an OpenAPI schema provides the `application/vnd.api+json` media
type. This rule is specifically useful for APIs that adhere to the JSON:API
specification.

## Configuration

None.

## Examples

**Good**. By marking the response with the correct media type, API authors
enable enhancements specific to JSON:API.

```yaml
openapi: 3.1.0
info: ...
paths:
  /users:
    get:
      responses:
        "200":
          description: A list of users.
          content:
            application/vnd.api+json:
              schema:
                $ref: "#/components/schemas/UserListResponse"
```

**Bad**. Although the response is a valid JSON:API document, it is not obvious
from this definition.

```yaml
openapi: 3.1.0
info: ...
paths:
  /users:
    get:
      responses:
        "200":
          description: A list of users.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UserListResponse"
```

## When Not to Use It

If the API is not meant to be JSON:API compatible.

## Automatic fixes

When invoked with `--fix`, a sole `application/json` content entry is renamed
to `application/vnd.api+json`, preserving its full media-type value. Content
maps with multiple entries remain manual.

## Compatibility

This rule is compatible with all OpenAPI 3.x version.
