Skip to content

Commit

Permalink
Tuned some of the responses in rules after reviewing report.
Browse files Browse the repository at this point in the history
  • Loading branch information
daveshanley committed Jul 19, 2022
1 parent 57af49e commit a84868e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
6 changes: 3 additions & 3 deletions functions/openapi/examples.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,8 @@ func analyzeExample(nameNodeValue string, mediaTypeNode *yaml.Node, basePath str
// check if the example contains a summary
_, summaryNode := utils.FindKeyNode("summary", []*yaml.Node{multiExampleNode})
if summaryNode == nil {
z := model.BuildFunctionResultString(fmt.Sprintf("Example `%s` missing a `summary`, "+
"examples need explaining", exampleName))
z := model.BuildFunctionResultString(fmt.Sprintf("Example `%s` missing a `summary` "+
"- examples need explaining", exampleName))
z.StartNode = esValue
z.EndNode = valueNode
z.Path = nodePath
Expand All @@ -486,7 +486,7 @@ func analyzeExample(nameNodeValue string, mediaTypeNode *yaml.Node, basePath str
// can`t both have a value and an external value set!
if valueNode != nil && externalValueNode != nil {
z := model.BuildFunctionResultString(fmt.Sprintf("Example `%s` is not valid: cannot use"+
" both `value` and `externalValue`, choose one or the other",
" both `value` and `externalValue` - choose one or the other",
exampleName))
z.StartNode = esValue
z.EndNode = valueNode
Expand Down
4 changes: 2 additions & 2 deletions functions/openapi/operation_descriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (od OperationDescription) RunRule(nodes []*yaml.Node, context model.RuleFun
descKey, descNode = utils.FindKeyNode("description", requestBodyNode.Content)

if descNode == nil {
res := createDescriptionResult(fmt.Sprintf("Operation requestBody `%s` at path `%s` "+
res := createDescriptionResult(fmt.Sprintf("Operation `requestBody` for method `%s` at path `%s` "+
"is missing a description", opMethod, opPath),
utils.BuildPath(basePath, []string{"requestBody"}), requestBodyKey, requestBodyNode)
res.Rule = context.Rule
Expand All @@ -95,7 +95,7 @@ func (od OperationDescription) RunRule(nodes []*yaml.Node, context model.RuleFun
words := strings.Split(descNode.Value, " ")
if len(words) < minWords {

res := createDescriptionResult(fmt.Sprintf("Operation `%s` requestBody description "+
res := createDescriptionResult(fmt.Sprintf("Operation `requestBody` for method `%s` description "+
"at path `%s` must be at least %d words long, (%d is not enough)", opMethod, opPath,
minWords, len(words)), basePath, descKey, descNode)
res.Rule = context.Rule
Expand Down
3 changes: 3 additions & 0 deletions functions/openapi/paths_kebab_case.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ func (vp PathsKebabCase) RunRule(nodes []*yaml.Node, context model.RuleFunctionC
continue
}
path := fmt.Sprintf("$.paths.%s", opPath)
if opPath == "/" {
continue
}
notKebab, segments := checkPathCase(opPath)
if notKebab {
results = append(results, model.RuleFunctionResult{
Expand Down
2 changes: 1 addition & 1 deletion functions/openapi/success_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (sr SuccessResponse) RunRule(nodes []*yaml.Node, context model.RuleFunction
}

results = append(results, model.RuleFunctionResult{
Message: fmt.Sprintf("Operation `%s` must define at least a single 2xx or 3xx response", name),
Message: fmt.Sprintf("Operation `%s` must define at least a single `2xx` or `3xx` response", name),
StartNode: fieldNode,
EndNode: endNode,
Path: fmt.Sprintf("$.paths.%s.%s.%s", currentPath, currentVerb, context.RuleAction.Field),
Expand Down
2 changes: 1 addition & 1 deletion rulesets/ruleset_functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1180,7 +1180,7 @@ func GetPathsKebabCaseRule() *model.Rule {
Recommended: true,
RuleCategory: model.RuleCategories[model.CategoryOperations],
Type: validation,
Severity: err,
Severity: warn,
Then: model.RuleAction{
Function: "pathsKebabCase",
},
Expand Down

0 comments on commit a84868e

Please sign in to comment.