diff options
author | 6543 <6543@obermui.de> | 2020-09-01 16:01:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-01 10:01:23 -0400 |
commit | 3270e7a4435fceb757728dfc319fc04077a37caf (patch) | |
tree | 60dcaf02442e930c0b2c7bd7fe0f0b00190a402f /vendor/github.com/go-openapi/validate/helpers.go | |
parent | 66843f22375b67a58746dac508b71200a96e68d6 (diff) | |
download | gitea-3270e7a4435fceb757728dfc319fc04077a37caf.tar.gz gitea-3270e7a4435fceb757728dfc319fc04077a37caf.zip |
[Vendor] update go-swagger v0.21.0 -> v0.25.0 (#12670)
* Update go-swagger
* vendor
Diffstat (limited to 'vendor/github.com/go-openapi/validate/helpers.go')
-rw-r--r-- | vendor/github.com/go-openapi/validate/helpers.go | 75 |
1 files changed, 67 insertions, 8 deletions
diff --git a/vendor/github.com/go-openapi/validate/helpers.go b/vendor/github.com/go-openapi/validate/helpers.go index 7ac8771094..4b77a00047 100644 --- a/vendor/github.com/go-openapi/validate/helpers.go +++ b/vendor/github.com/go-openapi/validate/helpers.go @@ -26,8 +26,67 @@ import ( "github.com/go-openapi/spec" ) -const swaggerBody = "body" -const objectType = "object" +const ( + swaggerBody = "body" + swaggerExample = "example" + swaggerExamples = "examples" +) + +const ( + objectType = "object" + arrayType = "array" + stringType = "string" + integerType = "integer" + numberType = "number" + booleanType = "boolean" + fileType = "file" + nullType = "null" +) + +const ( + jsonProperties = "properties" + jsonItems = "items" + jsonType = "type" + //jsonSchema = "schema" + jsonDefault = "default" +) + +const ( + stringFormatDate = "date" + stringFormatDateTime = "date-time" + stringFormatPassword = "password" + stringFormatByte = "byte" + //stringFormatBinary = "binary" + stringFormatCreditCard = "creditcard" + stringFormatDuration = "duration" + stringFormatEmail = "email" + stringFormatHexColor = "hexcolor" + stringFormatHostname = "hostname" + stringFormatIPv4 = "ipv4" + stringFormatIPv6 = "ipv6" + stringFormatISBN = "isbn" + stringFormatISBN10 = "isbn10" + stringFormatISBN13 = "isbn13" + stringFormatMAC = "mac" + stringFormatBSONObjectID = "bsonobjectid" + stringFormatRGBColor = "rgbcolor" + stringFormatSSN = "ssn" + stringFormatURI = "uri" + stringFormatUUID = "uuid" + stringFormatUUID3 = "uuid3" + stringFormatUUID4 = "uuid4" + stringFormatUUID5 = "uuid5" + + integerFormatInt32 = "int32" + integerFormatInt64 = "int64" + integerFormatUInt32 = "uint32" + integerFormatUInt64 = "uint64" + + numberFormatFloat32 = "float32" + numberFormatFloat64 = "float64" + numberFormatFloat = "float" + numberFormatDouble = "double" +) // Helpers available at the package level var ( @@ -205,7 +264,8 @@ func (h *paramHelper) checkExpandedParam(pr *spec.Parameter, path, in, operation res := new(Result) simpleZero := spec.SimpleSchema{} // Try to explain why... best guess - if pr.In == swaggerBody && (pr.SimpleSchema != simpleZero && pr.SimpleSchema.Type != objectType) { + switch { + case pr.In == swaggerBody && (pr.SimpleSchema != simpleZero && pr.SimpleSchema.Type != objectType): if isRef { // Most likely, a $ref with a sibling is an unwanted situation: in itself this is a warning... // but we detect it because of the following error: @@ -213,13 +273,12 @@ func (h *paramHelper) checkExpandedParam(pr *spec.Parameter, path, in, operation res.AddWarnings(refShouldNotHaveSiblingsMsg(path, operation)) } res.AddErrors(invalidParameterDefinitionMsg(path, in, operation)) - } else if pr.In != swaggerBody && pr.Schema != nil { + case pr.In != swaggerBody && pr.Schema != nil: if isRef { res.AddWarnings(refShouldNotHaveSiblingsMsg(path, operation)) } res.AddErrors(invalidParameterDefinitionAsSchemaMsg(path, in, operation)) - } else if (pr.In == swaggerBody && pr.Schema == nil) || - (pr.In != swaggerBody && pr.SimpleSchema == simpleZero) { // Safeguard + case (pr.In == swaggerBody && pr.Schema == nil) || (pr.In != swaggerBody && pr.SimpleSchema == simpleZero): // Other unexpected mishaps res.AddErrors(invalidParameterDefinitionMsg(path, in, operation)) } @@ -254,8 +313,8 @@ func (r *responseHelper) responseMsgVariants( responseType string, responseCode int) (responseName, responseCodeAsStr string) { // Path variants for messages - if responseType == "default" { - responseCodeAsStr = "default" + if responseType == jsonDefault { + responseCodeAsStr = jsonDefault responseName = "default response" } else { responseCodeAsStr = strconv.Itoa(responseCode) |