Skip to content

Commit d1c8185

Browse files
authored
chore/bring back yaml (#5)
* allow other content types like text/html * setup semantic release * chore: yaml dependency explicitly required
1 parent b47e8e9 commit d1c8185

9 files changed

Lines changed: 39 additions & 15 deletions

File tree

.spectral.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ rules:
4848
content-type:
4949
description: |-
5050
51-
Requests and responses **MUST** all use the content type of `application/vnd.api+json`.
51+
JSON payloads in requests and responses **MUST** use the content type of `application/vnd.api+json`.
52+
53+
Non-JSON media types can be used for endpoints that do not exchange JSON:API documents.
5254
5355
**Invalid Examples:**
5456
```yaml
@@ -76,7 +78,7 @@ rules:
7678
7779
Related specification information can be found [here](https://jsonapi.org/format/1.1/#content-negotiation-servers).
7880
documentationUrl: https://jsonapi.org/format/1.1/#content-negotiation
79-
message: Use application/vnd.api+json for all request and response bodies.
81+
message: Use application/vnd.api+json for JSON request and response bodies.
8082
severity: error
8183
given:
8284
- $.paths..requestBody.content
@@ -85,7 +87,7 @@ rules:
8587
field: "@key"
8688
function: pattern
8789
functionOptions:
88-
match: ^application/vnd\.api\+json;?
90+
notMatch: ^(?!application/vnd\.api\+json(?:\s*;.*)?$)[^/]+/(?:[^;]+\+json|json)(?:\s*;.*)?$
8991
406-response-code:
9092
description: |-
9193
Servers **MUST** describe response code **406** paths in case of invalid `Accept` values.

dist/ruleset.d.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ declare const _default: {
2828
field: string;
2929
function: _stoplight_spectral_core.RulesetFunctionWithValidator<string, _stoplight_spectral_functions.PatternOptions>;
3030
functionOptions: {
31-
match: string;
31+
notMatch: string;
3232
};
3333
};
3434
};

dist/ruleset.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ declare const _default: {
2828
field: string;
2929
function: _stoplight_spectral_core.RulesetFunctionWithValidator<string, _stoplight_spectral_functions.PatternOptions>;
3030
functionOptions: {
31-
match: string;
31+
notMatch: string;
3232
};
3333
};
3434
};

dist/ruleset.js

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ruleset.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ruleset.mjs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,9 @@ This ruleset can be found on GitHub: [spectral-jsonapi](https://github.com/phils
504504
rules: {
505505
"content-type": {
506506
description: `
507-
Requests and responses **MUST** all use the content type of \`application/vnd.api+json\`.
507+
JSON payloads in requests and responses **MUST** use the content type of \`application/vnd.api+json\`.
508+
509+
Non-JSON media types can be used for endpoints that do not exchange JSON:API documents.
508510
509511
**Invalid Examples:**
510512
\`\`\`yaml
@@ -532,14 +534,14 @@ responses:
532534
533535
Related specification information can be found [here](https://jsonapi.org/format/1.1/#content-negotiation-servers).`,
534536
documentationUrl: "https://jsonapi.org/format/1.1/#content-negotiation",
535-
message: "Use application/vnd.api+json for all request and response bodies.",
537+
message: "Use application/vnd.api+json for JSON request and response bodies.",
536538
severity: DiagnosticSeverity.Error,
537539
given: ["$.paths..requestBody.content", "$.paths..responses..content"],
538540
then: {
539541
field: "@key",
540542
function: pattern,
541543
functionOptions: {
542-
match: "^application/vnd\\.api\\+json;?"
544+
notMatch: "^(?!application/vnd\\.api\\+json(?:\\s*;.*)?$)[^/]+/(?:[^;]+\\+json|json)(?:\\s*;.*)?$"
543545
}
544546
}
545547
},

dist/ruleset.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 18 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@
6666
"semantic-release": "^25.0.3",
6767
"ts-jest": "^29.4.0",
6868
"tsup": "^8.5",
69-
"typescript": "^5.9"
69+
"typescript": "^5.9",
70+
"yaml": "^2.8.3"
7071
},
7172
"tsup": {
7273
"entry": [

0 commit comments

Comments
 (0)