mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-06 12:37:49 +00:00
Updated model builder to use lowercase checks only. **breaking change**
The case checking seems kinda dumb now looking back at this code. I am not sure why I felt the need to do that, however after being aware of it for some time and not being happy with the extra cycles it puts the code through. This change removes ConvertCase from the utils package, as it's no longer used or needed right now. If it needs co come back, we can re-add the code, but deleting code always makes me happy. It also removed a dependency from the project, which reduces the footprint, great!
This commit is contained in:
@@ -3,7 +3,6 @@ package utils
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/iancoleman/strcase"
|
||||
"github.com/vmware-labs/yaml-jsonpath/pkg/yamlpath"
|
||||
"gopkg.in/yaml.v3"
|
||||
"regexp"
|
||||
@@ -206,7 +205,7 @@ type KeyNodeSearch struct {
|
||||
func FindKeyNodeTop(key string, nodes []*yaml.Node) (keyNode *yaml.Node, valueNode *yaml.Node) {
|
||||
|
||||
for i, v := range nodes {
|
||||
if key == v.Value {
|
||||
if strings.ToLower(key) == strings.ToLower(v.Value) {
|
||||
return v, nodes[i+1] // next node is what we need.
|
||||
}
|
||||
}
|
||||
@@ -538,26 +537,6 @@ func RenderCodeSnippet(startNode *yaml.Node, specData []string, before, after in
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
func ConvertCase(input string, convert Case) string {
|
||||
if input == "" {
|
||||
return ""
|
||||
}
|
||||
switch convert {
|
||||
case PascalCase:
|
||||
return strcase.ToCamel(input)
|
||||
case CamelCase:
|
||||
return strcase.ToLowerCamel(input)
|
||||
case ScreamingKebabCase:
|
||||
return strcase.ToScreamingKebab(input)
|
||||
case ScreamingSnakeCase:
|
||||
return strcase.ToScreamingSnake(input)
|
||||
case SnakeCase:
|
||||
return strcase.ToSnake(input)
|
||||
default:
|
||||
return input
|
||||
}
|
||||
}
|
||||
|
||||
func DetectCase(input string) Case {
|
||||
trim := strings.TrimSpace(input)
|
||||
if trim == "" {
|
||||
|
||||
Reference in New Issue
Block a user