Skip to content

Commit

Permalink
fix: brought back request-support-json-oas3 rule
Browse files Browse the repository at this point in the history
  • Loading branch information
philsturgeon committed Aug 16, 2022
2 parents a070c6e + 184fdfa commit 8e2d856
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ testRule("request-support-json-oas3", [
},
errors: [
{
message: "Every request SHOULD support `application/json` media type.",
message: 'Every request SHOULD support at least one `application/json` content type.',
path: ["paths", "/", "get", "requestBody", "content"],
severity: DiagnosticSeverity.Warning,
},
Expand Down
29 changes: 18 additions & 11 deletions src/ruleset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,17 +215,24 @@ export default {
},

// Author: Andrzej (https://github.com/jerzyn)
// TODO: Not working, send in your improvements via a PR if you can!
// 'request-support-json-oas3': {
// description: 'Every request SHOULD support at least one `application/json` content type.',
// given: "$.paths.[*].requestBody.content[?(@property.match(/json/))]",
// then: {
// function: length,
// min: 1,
// },
// formats: [oas3],
// severity: DiagnosticSeverity.Warning,
// },
'request-support-json-oas3': {
description: 'Every request SHOULD support at least one `application/json` content type.',
given: "$.paths[*][*].requestBody.content",
then: {
function: schema,
functionOptions: {
schema: {
type: 'object',
properties: {
'application/json': true
},
required: ['application/json']
}
}
},
formats: [oas3],
severity: DiagnosticSeverity.Warning,
},

// Author: Phil Sturgeon (https://github.com/philsturgeon)
'no-unknown-error-format': {
Expand Down

0 comments on commit 8e2d856

Please sign in to comment.