// ContentType validates the content type of a request func validateContentType(allowed []string, actual string) *errors.Validation { mt, _, err := mime.ParseMediaType(actual) if err != nil { return errors.InvalidContentType(actual, allowed) } if swag.ContainsStringsCI(allowed, mt) { return nil } return errors.InvalidContentType(actual, allowed) }
}, "camelize": swag.ToJSONName, "humanize": swag.ToHumanNameLower, "snakize": swag.ToFileName, "dasherize": swag.ToCommandName, "pluralizeFirstWord": func(arg string) string { sentence := strings.Split(arg, " ") if len(sentence) == 1 { return inflect.Pluralize(arg) } return inflect.Pluralize(sentence[0]) + " " + strings.Join(sentence[1:], " ") }, "json": asJSON, "hasInsecure": func(arg []string) bool { return swag.ContainsStringsCI(arg, "http") || swag.ContainsStringsCI(arg, "ws") }, "hasSecure": func(arg []string) bool { return swag.ContainsStringsCI(arg, "https") || swag.ContainsStringsCI(arg, "wss") }, "stripPackage": func(str, pkg string) string { parts := strings.Split(str, ".") strlen := len(parts) if strlen > 0 { return parts[strlen-1] } return str }, "dropPackage": func(str string) string { parts := strings.Split(str, ".") strlen := len(parts)
func isEnabled(nm string) bool { return swag.ContainsStringsCI(enabled, nm) }