Skip to content

Commit

Permalink
removed dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
daveshanley committed Apr 21, 2024
1 parent 1c37e79 commit 0762d3c
Showing 1 changed file with 0 additions and 326 deletions.
326 changes: 0 additions & 326 deletions functions/openapi/operation_descriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,333 +162,7 @@ func (od OperationDescription) RunRule(nodes []*yaml.Node, context model.RuleFun
operation.Trace.RequestBody, operation.Trace.Responses, operation.Trace)
}

// if operation.Put != nil {
// checkDescription(operation.Put.Value.Description, http.MethodPut, fmt.Sprintf("at path `%s`", path),
// "description", operation.Put.GenerateJSONPath(), operation.Value.GoLow().KeyNode, operation.Put)
//
// checkDescription(operation.Put.Value.Summary, http.MethodPut, fmt.Sprintf("at path `%s`", path),
// "summary", operation.Put.GenerateJSONPath(), operation.Value.GoLow().KeyNode, operation.Put)
//
// // check request body
// if operation.Put.RequestBody != nil {
// checkDescription(operation.Put.Value.RequestBody.Description, http.MethodPut, fmt.Sprintf("`requestBody` at path `%s`", path),
// "description", operation.Put.GenerateJSONPath(),
// operation.Put.RequestBody.Value.GoLow().KeyNode, operation.Put)
// }
//
// // check responses
// if operation.Put.Responses != nil {
// for responsePairs := operation.Put.Responses.Codes.First(); responsePairs != nil; responsePairs = responsePairs.Next() {
// code := responsePairs.Key()
// response := responsePairs.Value()
// checkDescription(response.Value.Description, http.MethodPut, fmt.Sprintf("code `%s` `responseBody` at path `%s`", code, path),
// "description", response.GenerateJSONPath(), response.Value.GoLow().KeyNode, response)
// }
//
// }
// }
//
// if operation.Post != nil {
// checkDescription(operation.Post.Value.Description, http.MethodPost, fmt.Sprintf("at path `%s`", path),
// "description", operation.Post.GenerateJSONPath(), operation.Value.GoLow().KeyNode, operation.Post)
//
// checkDescription(operation.Post.Value.Summary, http.MethodPost, fmt.Sprintf("at path `%s`", path),
// "summary", operation.Post.GenerateJSONPath(), operation.Value.GoLow().KeyNode, operation.Post)
//
// // check request body
// if operation.Post.RequestBody != nil {
// checkDescription(operation.Post.Value.RequestBody.Description, http.MethodPost, fmt.Sprintf("`requestBody` at path `%s`", path),
// "description", operation.Post.GenerateJSONPath(),
// operation.Post.RequestBody.Value.GoLow().KeyNode, operation.Post)
// }
//
// // check responses
// if operation.Post.Responses != nil {
// for responsePairs := operation.Post.Responses.Codes.First(); responsePairs != nil; responsePairs = responsePairs.Next() {
// code := responsePairs.Key()
// response := responsePairs.Value()
// checkDescription(response.Value.Description, http.MethodPost, fmt.Sprintf("code `%s` `responseBody` at path `%s`", code, path),
// "description", response.GenerateJSONPath(), response.Value.GoLow().KeyNode, response)
// }
//
// }
// }
//
// if operation.Delete != nil {
// checkDescription(operation.Delete.Value.Description, http.MethodDelete, fmt.Sprintf("at path `%s`", path),
// "description", operation.Delete.GenerateJSONPath(), operation.Value.GoLow().KeyNode, operation.Delete)
//
// checkDescription(operation.Delete.Value.Summary, http.MethodDelete, fmt.Sprintf("at path `%s`", path),
// "summary", operation.Delete.GenerateJSONPath(), operation.Value.GoLow().KeyNode, operation.Delete)
//
// // check request body
// if operation.Delete.RequestBody != nil {
// checkDescription(operation.Delete.Value.RequestBody.Description, http.MethodDelete, fmt.Sprintf("`requestBody` at path `%s`", path),
// "description", operation.Delete.GenerateJSONPath(),
// operation.Delete.RequestBody.Value.GoLow().KeyNode, operation.Delete)
// }
//
// // check responses
// if operation.Delete.Responses != nil {
// for responsePairs := operation.Delete.Responses.Codes.First(); responsePairs != nil; responsePairs = responsePairs.Next() {
// code := responsePairs.Key()
// response := responsePairs.Value()
// checkDescription(response.Value.Description, http.MethodDelete, fmt.Sprintf("code `%s` `responseBody` at path `%s`", code, path),
// "description", response.GenerateJSONPath(), response.Value.GoLow().KeyNode, response)
// }
//
// }
// }
//
// if operation.Options != nil {
// checkDescription(operation.Options.Value.Description, http.MethodOptions, fmt.Sprintf("at path `%s`", path),
// "description", operation.Options.GenerateJSONPath(), operation.Value.GoLow().KeyNode, operation.Options)
//
// checkDescription(operation.Options.Value.Summary, http.MethodOptions, fmt.Sprintf("at path `%s`", path),
// "summary", operation.Options.GenerateJSONPath(), operation.Value.GoLow().KeyNode, operation.Options)
//
// // check request body
// if operation.Options.RequestBody != nil {
// checkDescription(operation.Options.Value.RequestBody.Description, http.MethodOptions, fmt.Sprintf("`requestBody` at path `%s`", path),
// "description", operation.Options.GenerateJSONPath(),
// operation.Options.RequestBody.Value.GoLow().KeyNode, operation.Options)
// }
//
// // check responses
// if operation.Options.Responses != nil {
// for responsePairs := operation.Options.Responses.Codes.First(); responsePairs != nil; responsePairs = responsePairs.Next() {
// code := responsePairs.Key()
// response := responsePairs.Value()
// checkDescription(response.Value.Description, http.MethodOptions, fmt.Sprintf("code `%s` `responseBody` at path `%s`", code, path),
// "description", response.GenerateJSONPath(), response.Value.GoLow().KeyNode, response)
// }
//
// }
// }
//
// if operation.Head != nil {
// checkDescription(operation.Head.Value.Description, http.MethodHead, fmt.Sprintf("at path `%s`", path),
// "description", operation.Head.GenerateJSONPath(), operation.Value.GoLow().KeyNode, operation.Head)
//
// checkDescription(operation.Head.Value.Summary, http.MethodHead, fmt.Sprintf("at path `%s`", path),
// "summary", operation.Head.GenerateJSONPath(), operation.Value.GoLow().KeyNode, operation.Head)
//
// // check request body
// if operation.Head.RequestBody != nil {
// checkDescription(operation.Head.Value.RequestBody.Description, http.MethodHead, fmt.Sprintf("`requestBody` at path `%s`", path),
// "description", operation.Head.GenerateJSONPath(),
// operation.Head.RequestBody.Value.GoLow().KeyNode, operation.Head)
// }
//
// // check responses
// if operation.Head.Responses != nil {
// for responsePairs := operation.Head.Responses.Codes.First(); responsePairs != nil; responsePairs = responsePairs.Next() {
// code := responsePairs.Key()
// response := responsePairs.Value()
// checkDescription(response.Value.Description, http.MethodHead, fmt.Sprintf("code `%s` `responseBody` at path `%s`", code, path),
// "description", response.GenerateJSONPath(), response.Value.GoLow().KeyNode, response)
// }
//
// }
// }
//
// if operation.Patch != nil {
// checkDescription(operation.Patch.Value.Description, http.MethodPatch, fmt.Sprintf("at path `%s`", path),
// "description", operation.Patch.GenerateJSONPath(), operation.Value.GoLow().KeyNode, operation.Patch)
//
// checkDescription(operation.Patch.Value.Summary, http.MethodPatch, fmt.Sprintf("at path `%s`", path),
// "summary", operation.Patch.GenerateJSONPath(), operation.Value.GoLow().KeyNode, operation.Patch)
//
// // check request body
// if operation.Patch.RequestBody != nil {
// checkDescription(operation.Patch.Value.RequestBody.Description, http.MethodPatch, fmt.Sprintf("`requestBody` at path `%s`", path),
// "description", operation.Patch.GenerateJSONPath(),
// operation.Patch.RequestBody.Value.GoLow().KeyNode, operation.Patch)
// }
//
// // check responses
// if operation.Patch.Responses != nil {
// for responsePairs := operation.Patch.Responses.Codes.First(); responsePairs != nil; responsePairs = responsePairs.Next() {
// code := responsePairs.Key()
// response := responsePairs.Value()
// checkDescription(response.Value.Description, http.MethodPatch, fmt.Sprintf("code `%s` `responseBody` at path `%s`", code, path),
// "description", response.GenerateJSONPath(), response.Value.GoLow().KeyNode, response)
// }
//
// }
// }
//
// if operation.Trace != nil {
// checkDescription(operation.Trace.Value.Description, http.MethodTrace, fmt.Sprintf("at path `%s`", path),
// "description", operation.Trace.GenerateJSONPath(), operation.Value.GoLow().KeyNode, operation.Trace)
//
// checkDescription(operation.Trace.Value.Summary, http.MethodTrace, fmt.Sprintf("at path `%s`", path),
// "summary", operation.Trace.GenerateJSONPath(), operation.Value.GoLow().KeyNode, operation.Trace)
//
// // check request body
// if operation.Trace.RequestBody != nil {
// checkDescription(operation.Trace.Value.RequestBody.Description, http.MethodTrace, fmt.Sprintf("`requestBody` at path `%s`", path),
// "description", operation.Trace.GenerateJSONPath(),
// operation.Trace.RequestBody.Value.GoLow().KeyNode, operation.Trace)
// }
//
// // check responses
// if operation.Trace.Responses != nil {
// for responsePairs := operation.Trace.Responses.Codes.First(); responsePairs != nil; responsePairs = responsePairs.Next() {
// code := responsePairs.Key()
// response := responsePairs.Value()
// checkDescription(response.Value.Description, http.MethodTrace, fmt.Sprintf("code `%s` `responseBody` at path `%s`", code, path),
// "description", response.GenerateJSONPath(), response.Value.GoLow().KeyNode, response)
// }
//
// }
// }
}
}

//
//if context.Index.GetPathsNode() == nil {
// return results
//}
//ops := context.Index.GetPathsNode().Content
//
//var opPath, opMethod string
//for i, op := range ops {
// if i%2 == 0 {
// opPath = op.Value
// continue
// }
//
// skip := false
// for m, method := range op.Content {
//
// if m%2 == 0 {
// opMethod = method.Value
// if skip {
// skip = false
// }
// continue
// }
// // skip non-operations
// switch opMethod {
// case
// // No v2.*Label here, they're duplicates
// v3.GetLabel, v3.PutLabel, v3.PostLabel, v3.DeleteLabel, v3.OptionsLabel, v3.HeadLabel, v3.PatchLabel, v3.TraceLabel:
// // Ok, an operation
// default:
// skip = true
// continue
// }
// if skip {
// skip = false
// continue
// }
//
// basePath := fmt.Sprintf("$.paths['%s'].%s", opPath, opMethod)
// descKey, descNode := utils.FindKeyNodeTop("description", method.Content)
// _, summNode := utils.FindKeyNodeTop("summary", method.Content)
// requestBodyKey, requestBodyNode := utils.FindKeyNodeTop("requestBody", method.Content)
// _, responsesNode := utils.FindKeyNode("responses", method.Content)
//
// if descNode == nil {
//
// // if there is no summary either, then report
// if summNode == nil {
// res := createDescriptionResult(fmt.Sprintf("operation `%s` at path `%s` is missing a description and a summary",
// opMethod, opPath), basePath, method, method)
// res.Rule = context.Rule
// results = append(results, res)
// }
//
// } else {
//
// // check if description is above a certain length of words
// words := strings.Split(descNode.Value, " ")
// if len(words) < minWords {
//
// res := createDescriptionResult(fmt.Sprintf("operation `%s` description at path `%s` must be "+
// "at least %d words long, (%d is not enough)", opMethod, opPath, minWords, len(words)), basePath, descKey, descKey)
// res.Rule = context.Rule
// results = append(results, res)
// }
// }
// // check operation request body
// if requestBodyNode != nil {
//
// descKey, descNode = utils.FindKeyNodeTop("description", requestBodyNode.Content)
// _, summNode = utils.FindKeyNodeTop("summary", requestBodyNode.Content)
//
// if descNode == nil {
//
// // if there is no summary either, then report
// if summNode == nil {
// res := createDescriptionResult(fmt.Sprintf("field `requestBody` for operation `%s` at path `%s` "+
// "is missing a description and a summary", opMethod, opPath),
// utils.BuildPath(basePath, []string{"requestBody"}), requestBodyKey, requestBodyKey)
// res.Rule = context.Rule
// results = append(results, res)
// }
//
// } else {
//
// // check if request body description is above a certain length of words
// words := strings.Split(descNode.Value, " ")
// if len(words) < minWords {
//
// res := createDescriptionResult(fmt.Sprintf("field `requestBody` for operation `%s` description "+
// "at path `%s` must be at least %d words long, (%d is not enough)", opMethod, opPath,
// minWords, len(words)), basePath, descKey, descKey)
// res.Rule = context.Rule
// results = append(results, res)
// }
// }
// }
//
// // check operation responses
// if responsesNode != nil {
//
// // run through each response.
// var opCode string
// var opCodeNode *yaml.Node
// for z, response := range responsesNode.Content {
// if z%2 == 0 {
// opCode = response.Value
// opCodeNode = response
// continue
// }
// if strings.HasPrefix(opCode, "x-") {
// continue
// }
//
// descKey, descNode = utils.FindKeyNodeTop("description", response.Content)
// _, summNode = utils.FindKeyNodeTop("summary", response.Content)
//
// if descNode == nil {
//
// // if there is no summary either, then report
// if summNode == nil {
// res := createDescriptionResult(fmt.Sprintf("operation `%s` response `%s` "+
// "at path `%s` is missing a description and a summary", opMethod, opCode, opPath),
// utils.BuildPath(basePath, []string{"requestBody"}), opCodeNode, opCodeNode)
// res.Rule = context.Rule
// results = append(results, res)
// }
// } else {
//
// // check if response description is above a certain length of words
// words := strings.Split(descNode.Value, " ")
// if len(words) < minWords {
//
// res := createDescriptionResult(fmt.Sprintf("operation `%s` response `%s` "+
// "description at path `%s` must be at least %d words long, (%d is not enough)", opMethod, opCode, opPath,
// minWords, len(words)), basePath, descKey, descKey)
// res.Rule = context.Rule
// results = append(results, res)
// }
// }
// }
// }
// }
//}
return results
}

0 comments on commit 0762d3c

Please sign in to comment.