in cmd/generator/cloudspec/spec_commands.go [37:74]
func GetCommands(cloudSpec *spec.Swagger, w io.Writer, version string) {
var commands = make([]string, 0, len(cloudSpec.Paths.Paths))
// Iterate over the paths and parameters as well.
// nolint rangeValCopy: each iteration copies 128 bytes (consider pointers or indexing)
for path, pathItem := range cloudSpec.Paths.Paths {
var command []string
if pathItem.Head != nil {
command = append(command, bulletCommand(pathItem.Head.ID, path, "HEAD"))
}
if pathItem.Get != nil {
command = append(command, bulletCommand(pathItem.Get.ID, path, "GET"))
}
if pathItem.Post != nil {
command = append(command, bulletCommand(pathItem.Post.ID, path, "POST"))
}
if pathItem.Put != nil {
command = append(command, bulletCommand(pathItem.Put.ID, path, "PUT"))
}
if pathItem.Patch != nil {
command = append(command, bulletCommand(pathItem.Patch.ID, path, "PATCH"))
}
if pathItem.Delete != nil {
command = append(command, bulletCommand(pathItem.Delete.ID, path, "DELETE"))
}
commands = append(commands, command...)
}
sort.SliceStable(commands, func(i, j int) bool {
return commands[i] < commands[j]
})
fmt.Fprintf(w, header, version, len(commands))
for i := range commands {
fmt.Fprintln(w, commands[i])
}
}