Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .spectral.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ rules:
content-type:
description: |-

Requests and responses **MUST** all use the content type of `application/vnd.api+json`.
JSON payloads in requests and responses **MUST** use the content type of `application/vnd.api+json`.

Non-JSON media types can be used for endpoints that do not exchange JSON:API documents.

**Invalid Examples:**
```yaml
Expand Down Expand Up @@ -76,7 +78,7 @@ rules:

Related specification information can be found [here](https://jsonapi.org/format/1.1/#content-negotiation-servers).
documentationUrl: https://jsonapi.org/format/1.1/#content-negotiation
message: Use application/vnd.api+json for all request and response bodies.
message: Use application/vnd.api+json for JSON request and response bodies.
severity: error
given:
- $.paths..requestBody.content
Expand All @@ -85,7 +87,7 @@ rules:
field: "@key"
function: pattern
functionOptions:
match: ^application/vnd\.api\+json;?
notMatch: ^(?!application/vnd\.api\+json(?:\s*;.*)?$)[^/]+/(?:[^;]+\+json|json)(?:\s*;.*)?$
406-response-code:
description: |-
Servers **MUST** describe response code **406** paths in case of invalid `Accept` values.
Expand Down
2 changes: 1 addition & 1 deletion dist/ruleset.d.mts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ declare const _default: {
field: string;
function: _stoplight_spectral_core.RulesetFunctionWithValidator<string, _stoplight_spectral_functions.PatternOptions>;
functionOptions: {
match: string;
notMatch: string;
};
};
};
Expand Down
2 changes: 1 addition & 1 deletion dist/ruleset.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ declare const _default: {
field: string;
function: _stoplight_spectral_core.RulesetFunctionWithValidator<string, _stoplight_spectral_functions.PatternOptions>;
functionOptions: {
match: string;
notMatch: string;
};
};
};
Expand Down
8 changes: 5 additions & 3 deletions dist/ruleset.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/ruleset.js.map

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions dist/ruleset.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,9 @@ This ruleset can be found on GitHub: [spectral-jsonapi](https://github.com/phils
rules: {
"content-type": {
description: `
Requests and responses **MUST** all use the content type of \`application/vnd.api+json\`.
JSON payloads in requests and responses **MUST** use the content type of \`application/vnd.api+json\`.

Non-JSON media types can be used for endpoints that do not exchange JSON:API documents.

**Invalid Examples:**
\`\`\`yaml
Expand Down Expand Up @@ -532,14 +534,14 @@ responses:

Related specification information can be found [here](https://jsonapi.org/format/1.1/#content-negotiation-servers).`,
documentationUrl: "https://jsonapi.org/format/1.1/#content-negotiation",
message: "Use application/vnd.api+json for all request and response bodies.",
message: "Use application/vnd.api+json for JSON request and response bodies.",
severity: DiagnosticSeverity.Error,
given: ["$.paths..requestBody.content", "$.paths..responses..content"],
then: {
field: "@key",
function: pattern,
functionOptions: {
match: "^application/vnd\\.api\\+json;?"
notMatch: "^(?!application/vnd\\.api\\+json(?:\\s*;.*)?$)[^/]+/(?:[^;]+\\+json|json)(?:\\s*;.*)?$"
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion dist/ruleset.mjs.map

Large diffs are not rendered by default.

19 changes: 18 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@
"semantic-release": "^25.0.3",
"ts-jest": "^29.4.0",
"tsup": "^8.5",
"typescript": "^5.9"
"typescript": "^5.9",
"yaml": "^2.8.3"
},
"tsup": {
"entry": [
Expand Down