update prometheus dependencies (#5520)
Signed-off-by: junot <junotxiang@kubesphere.io>
This commit is contained in:
2
vendor/github.com/go-openapi/validate/.gitattributes
generated
vendored
Normal file
2
vendor/github.com/go-openapi/validate/.gitattributes
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
# gofmt always uses LF, whereas Git uses CRLF on Windows.
|
||||
*.go text eol=lf
|
||||
26
vendor/github.com/go-openapi/validate/.golangci.yml
generated
vendored
26
vendor/github.com/go-openapi/validate/.golangci.yml
generated
vendored
@@ -1,8 +1,6 @@
|
||||
linters-settings:
|
||||
govet:
|
||||
check-shadowing: true
|
||||
golint:
|
||||
min-confidence: 0
|
||||
gocyclo:
|
||||
min-complexity: 50
|
||||
maligned:
|
||||
@@ -26,3 +24,27 @@ linters:
|
||||
- gochecknoglobals
|
||||
- gochecknoinits
|
||||
- scopelint
|
||||
- wrapcheck
|
||||
- exhaustivestruct
|
||||
- exhaustive
|
||||
- nlreturn
|
||||
- testpackage
|
||||
- gci
|
||||
- gofumpt
|
||||
- goerr113
|
||||
- gomnd
|
||||
- tparallel
|
||||
- nestif
|
||||
- godot
|
||||
- tparallel
|
||||
- paralleltest
|
||||
- cyclop # because we have gocyclo already
|
||||
# TODO: review the linters below. We disabled them to make the CI pass first.
|
||||
- ireturn
|
||||
- varnamelen
|
||||
- forcetypeassert
|
||||
- thelper
|
||||
# Disable deprecated linters.
|
||||
# They will be removed from golangci-lint in future.
|
||||
- interfacer
|
||||
- golint
|
||||
17
vendor/github.com/go-openapi/validate/.travis.yml
generated
vendored
17
vendor/github.com/go-openapi/validate/.travis.yml
generated
vendored
@@ -1,17 +0,0 @@
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
go:
|
||||
- 1.13.x
|
||||
- 1.14.x
|
||||
install:
|
||||
- GO111MODULE=off go get -u gotest.tools/gotestsum
|
||||
language: go
|
||||
notifications:
|
||||
slack:
|
||||
secure: EmObnQuM9Mw8J9vpFaKKHqSMN4Wsr/A9+v7ewAD5cEhA0T1P4m7MbJMiJOhxUhj/X+BFh2DamW+P2lT8mybj5wg8wnkQ2BteKA8Tawi6f9PRw2NRheO8tAi8o/npLnlmet0kc93mn+oLuqHw36w4+j5mkOl2FghkfGiUVhwrhkCP7KXQN+3TU87e+/HzQumlJ3nsE+6terVxkH3PmaUTsS5ONaODZfuxFpfb7RsoEl3skHf6d+tr+1nViLxxly7558Nc33C+W1mr0qiEvMLZ+kJ/CpGWBJ6CUJM3jm6hNe2eMuIPwEK2hxZob8c7n22VPap4K6a0bBRoydoDXaba+2sD7Ym6ivDO/DVyL44VeBBLyIiIBylDGQdZH+6SoWm90Qe/i7tnY/T5Ao5igT8f3cfQY1c3EsTfqmlDfrhmACBmwSlgkdVBLTprHL63JMY24LWmh4jhxsmMRZhCL4dze8su1w6pLN/pD1pGHtKYCEVbdTmaM3PblNRFf12XB7qosmQsgUndH4Vq3bTbU0s1pKjeDhRyLvFzvR0TBbo0pDLEoF1A/i5GVFWa7yLZNUDudQERRh7qv/xBl2excIaQ1sV4DSVm7bAE9l6Kp+yeHQJW2uN6Y3X8wu9gB9nv9l5HBze7wh8KE6PyWAOLYYqZg9/sAtsv/2GcQqXcKFF1zcA=
|
||||
script:
|
||||
- gotestsum -f short-verbose -- -race ./...
|
||||
- gotestsum -f short-verbose -- -timeout=20m -coverprofile=coverage.txt -covermode=atomic -args -enable-long ./...
|
||||
- gotestsum -f short-verbose -- -timeout=30m -args -enable-go-swagger ./...
|
||||
- go get -u github.com/go-openapi/runtime@master
|
||||
- gotestsum -f short-verbose -- -timeout=30m github.com/go-openapi/runtime/...
|
||||
40
vendor/github.com/go-openapi/validate/README.md
generated
vendored
40
vendor/github.com/go-openapi/validate/README.md
generated
vendored
@@ -1,6 +1,38 @@
|
||||
# Validation helpers [](https://travis-ci.org/go-openapi/validate) [](https://codecov.io/gh/go-openapi/validate) [](https://slackin.goswagger.io)
|
||||
|
||||
# Validation helpers
|
||||
[](https://travis-ci.org/go-openapi/validate)
|
||||
[](https://ci.appveyor.com/project/fredbi/validate/branch/master)
|
||||
[](https://codecov.io/gh/go-openapi/validate)
|
||||
[](https://slackin.goswagger.io)
|
||||
[](https://raw.githubusercontent.com/go-openapi/validate/master/LICENSE)
|
||||
[](http://godoc.org/github.com/go-openapi/validate)
|
||||
[](https://golangci.com)
|
||||
[](https://pkg.go.dev/github.com/go-openapi/validate)
|
||||
[](https://goreportcard.com/report/github.com/go-openapi/validate)
|
||||
|
||||
This package provides helpers to validate Swagger 2.0. specification (aka OpenAPI 2.0).
|
||||
|
||||
Reference can be found here: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md.
|
||||
|
||||
## What's inside?
|
||||
|
||||
* A validator for Swagger specifications
|
||||
* A validator for JSON schemas draft4
|
||||
* Helper functions to validate individual values (used by code generated by [go-swagger](https://github.com/go-swagger/go-swagger)).
|
||||
* Required, RequiredNumber, RequiredString
|
||||
* ReadOnly
|
||||
* UniqueItems, MaxItems, MinItems
|
||||
* Enum, EnumCase
|
||||
* Pattern, MinLength, MaxLength
|
||||
* Minimum, Maximum, MultipleOf
|
||||
* FormatOf
|
||||
|
||||
[Documentation](https://godoc.org/github.com/go-openapi/validate)
|
||||
|
||||
## FAQ
|
||||
|
||||
* Does this library support OpenAPI 3?
|
||||
|
||||
> No.
|
||||
> This package currently only supports OpenAPI 2.0 (aka Swagger 2.0).
|
||||
> There is no plan to make it evolve toward supporting OpenAPI 3.x.
|
||||
> This [discussion thread](https://github.com/go-openapi/spec/issues/21) relates the full story.
|
||||
>
|
||||
> An early attempt to support Swagger 3 may be found at: https://github.com/go-openapi/spec3
|
||||
|
||||
32
vendor/github.com/go-openapi/validate/appveyor.yml
generated
vendored
Normal file
32
vendor/github.com/go-openapi/validate/appveyor.yml
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
version: "0.1.{build}"
|
||||
|
||||
clone_folder: C:\go-openapi\validate
|
||||
shallow_clone: true # for startup speed
|
||||
pull_requests:
|
||||
do_not_increment_build_number: true
|
||||
|
||||
#skip_tags: true
|
||||
#skip_branch_with_pr: true
|
||||
|
||||
# appveyor.yml
|
||||
build: off
|
||||
|
||||
environment:
|
||||
GOPATH: c:\gopath
|
||||
|
||||
stack: go 1.15
|
||||
|
||||
test_script:
|
||||
- go test -v -timeout 20m -args -enable-long ./...
|
||||
|
||||
deploy: off
|
||||
|
||||
notifications:
|
||||
- provider: Slack
|
||||
incoming_webhook: https://hooks.slack.com/services/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
|
||||
auth_token:
|
||||
secure: Sf7kZf7ZGbnwWUMpffHwMu5A0cHkLK2MYY32LNTPj4+/3qC3Ghl7+9v4TSLOqOlCwdRNjOGblAq7s+GDJed6/xgRQl1JtCi1klzZNrYX4q01pgTPvvGcwbBkIYgeMaPeIRcK9OZnud7sRXdttozgTOpytps2U6Js32ip7uj5mHSg2ub0FwoSJwlS6dbezZ8+eDhoha0F/guY99BEwx8Bd+zROrT2TFGsSGOFGN6wFc7moCqTHO/YkWib13a2QNXqOxCCVBy/lt76Wp+JkeFppjHlzs/2lP3EAk13RIUAaesdEUHvIHrzCyNJEd3/+KO2DzsWOYfpktd+KBCvgaYOsoo7ubdT3IROeAegZdCgo/6xgCEsmFc9ZcqCfN5yNx2A+BZ2Vwmpws+bQ1E1+B5HDzzaiLcYfG4X2O210QVGVDLWsv1jqD+uPYeHY2WRfh5ZsIUFvaqgUEnwHwrK44/8REAhQavt1QAj5uJpsRd7CkRVPWRNK+yIky+wgbVUFEchRNmS55E7QWf+W4+4QZkQi7vUTMc9nbTUu2Es9NfvfudOpM2wZbn98fjpb/qq/nRv6Bk+ca+7XD5/IgNLMbWp2ouDdzbiHLCOfDUiHiDJhLfFZx9Bwo7ZwfzeOlbrQX66bx7xRKYmOe4DLrXhNcpbsMa8qbfxlZRCmYbubB/Y8h4=
|
||||
channel: bots
|
||||
on_build_success: false
|
||||
on_build_failure: true
|
||||
on_build_status_changed: true
|
||||
56
vendor/github.com/go-openapi/validate/context.go
generated
vendored
Normal file
56
vendor/github.com/go-openapi/validate/context.go
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
package validate
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
// validateCtxKey is the key type of context key in this pkg
|
||||
type validateCtxKey string
|
||||
|
||||
const (
|
||||
operationTypeKey validateCtxKey = "operationTypeKey"
|
||||
)
|
||||
|
||||
type operationType string
|
||||
|
||||
const (
|
||||
request operationType = "request"
|
||||
response operationType = "response"
|
||||
none operationType = "none" // not specified in ctx
|
||||
)
|
||||
|
||||
var operationTypeEnum = []operationType{request, response, none}
|
||||
|
||||
// WithOperationRequest returns a new context with operationType request
|
||||
// in context value
|
||||
func WithOperationRequest(ctx context.Context) context.Context {
|
||||
return withOperation(ctx, request)
|
||||
}
|
||||
|
||||
// WithOperationRequest returns a new context with operationType response
|
||||
// in context value
|
||||
func WithOperationResponse(ctx context.Context) context.Context {
|
||||
return withOperation(ctx, response)
|
||||
}
|
||||
|
||||
func withOperation(ctx context.Context, operation operationType) context.Context {
|
||||
return context.WithValue(ctx, operationTypeKey, operation)
|
||||
}
|
||||
|
||||
// extractOperationType extracts the operation type from ctx
|
||||
// if not specified or of unknown value, return none operation type
|
||||
func extractOperationType(ctx context.Context) operationType {
|
||||
v := ctx.Value(operationTypeKey)
|
||||
if v == nil {
|
||||
return none
|
||||
}
|
||||
res, ok := v.(operationType)
|
||||
if !ok {
|
||||
return none
|
||||
}
|
||||
// validate the value is in operation enum
|
||||
if err := Enum("", "", res, operationTypeEnum); err != nil {
|
||||
return none
|
||||
}
|
||||
return res
|
||||
}
|
||||
22
vendor/github.com/go-openapi/validate/default_validator.go
generated
vendored
22
vendor/github.com/go-openapi/validate/default_validator.go
generated
vendored
@@ -92,7 +92,7 @@ func (d *defaultValidator) validateDefaultValueValidAgainstSchema() *Result {
|
||||
res := new(Result)
|
||||
s := d.SpecValidator
|
||||
|
||||
for method, pathItem := range s.analyzer.Operations() {
|
||||
for method, pathItem := range s.expandedAnalyzer().Operations() {
|
||||
for path, op := range pathItem {
|
||||
// parameters
|
||||
for _, param := range paramHelp.safeExpandedParamsFor(path, method, op.ID, res, s) {
|
||||
@@ -107,7 +107,7 @@ func (d *defaultValidator) validateDefaultValueValidAgainstSchema() *Result {
|
||||
// default values provided must validate against their inline definition (no explicit schema)
|
||||
if param.Default != nil && param.Schema == nil {
|
||||
// check param default value is valid
|
||||
red := NewParamValidator(¶m, s.KnownFormats).Validate(param.Default)
|
||||
red := NewParamValidator(¶m, s.KnownFormats).Validate(param.Default) //#nosec
|
||||
if red.HasErrorsOrWarnings() {
|
||||
res.AddErrors(defaultValueDoesNotValidateMsg(param.Name, param.In))
|
||||
res.Merge(red)
|
||||
@@ -116,7 +116,7 @@ func (d *defaultValidator) validateDefaultValueValidAgainstSchema() *Result {
|
||||
|
||||
// Recursively follows Items and Schemas
|
||||
if param.Items != nil {
|
||||
red := d.validateDefaultValueItemsAgainstSchema(param.Name, param.In, ¶m, param.Items)
|
||||
red := d.validateDefaultValueItemsAgainstSchema(param.Name, param.In, ¶m, param.Items) //#nosec
|
||||
if red.HasErrorsOrWarnings() {
|
||||
res.AddErrors(defaultValueItemsDoesNotValidateMsg(param.Name, param.In))
|
||||
res.Merge(red)
|
||||
@@ -141,7 +141,7 @@ func (d *defaultValidator) validateDefaultValueValidAgainstSchema() *Result {
|
||||
// Same constraint on regular Responses
|
||||
if op.Responses.StatusCodeResponses != nil { // Safeguard
|
||||
for code, r := range op.Responses.StatusCodeResponses {
|
||||
res.Merge(d.validateDefaultInResponse(&r, "response", path, code, op.ID))
|
||||
res.Merge(d.validateDefaultInResponse(&r, "response", path, code, op.ID)) //#nosec
|
||||
}
|
||||
}
|
||||
} else if op.ID != "" {
|
||||
@@ -154,7 +154,7 @@ func (d *defaultValidator) validateDefaultValueValidAgainstSchema() *Result {
|
||||
// reset explored schemas to get depth-first recursive-proof exploration
|
||||
d.resetVisited()
|
||||
for nm, sch := range s.spec.Spec().Definitions {
|
||||
res.Merge(d.validateDefaultValueSchemaAgainstSchema(fmt.Sprintf("definitions.%s", nm), "body", &sch))
|
||||
res.Merge(d.validateDefaultValueSchemaAgainstSchema(fmt.Sprintf("definitions.%s", nm), "body", &sch)) //#nosec
|
||||
}
|
||||
}
|
||||
return res
|
||||
@@ -177,7 +177,7 @@ func (d *defaultValidator) validateDefaultInResponse(resp *spec.Response, respon
|
||||
d.resetVisited()
|
||||
|
||||
if h.Default != nil {
|
||||
red := NewHeaderValidator(nm, &h, s.KnownFormats).Validate(h.Default)
|
||||
red := NewHeaderValidator(nm, &h, s.KnownFormats).Validate(h.Default) //#nosec
|
||||
if red.HasErrorsOrWarnings() {
|
||||
res.AddErrors(defaultValueHeaderDoesNotValidateMsg(operationID, nm, responseName))
|
||||
res.Merge(red)
|
||||
@@ -186,7 +186,7 @@ func (d *defaultValidator) validateDefaultInResponse(resp *spec.Response, respon
|
||||
|
||||
// Headers have inline definition, like params
|
||||
if h.Items != nil {
|
||||
red := d.validateDefaultValueItemsAgainstSchema(nm, "header", &h, h.Items)
|
||||
red := d.validateDefaultValueItemsAgainstSchema(nm, "header", &h, h.Items) //#nosec
|
||||
if red.HasErrorsOrWarnings() {
|
||||
res.AddErrors(defaultValueHeaderItemsDoesNotValidateMsg(operationID, nm, responseName))
|
||||
res.Merge(red)
|
||||
@@ -233,7 +233,7 @@ func (d *defaultValidator) validateDefaultValueSchemaAgainstSchema(path, in stri
|
||||
// Multiple schemas in items
|
||||
if schema.Items.Schemas != nil { // Safeguard
|
||||
for i, sch := range schema.Items.Schemas {
|
||||
res.Merge(d.validateDefaultValueSchemaAgainstSchema(fmt.Sprintf("%s.items[%d].default", path, i), in, &sch))
|
||||
res.Merge(d.validateDefaultValueSchemaAgainstSchema(fmt.Sprintf("%s.items[%d].default", path, i), in, &sch)) //#nosec
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -245,17 +245,17 @@ func (d *defaultValidator) validateDefaultValueSchemaAgainstSchema(path, in stri
|
||||
res.Merge(d.validateDefaultValueSchemaAgainstSchema(fmt.Sprintf("%s.additionalItems", path), in, schema.AdditionalItems.Schema))
|
||||
}
|
||||
for propName, prop := range schema.Properties {
|
||||
res.Merge(d.validateDefaultValueSchemaAgainstSchema(path+"."+propName, in, &prop))
|
||||
res.Merge(d.validateDefaultValueSchemaAgainstSchema(path+"."+propName, in, &prop)) //#nosec
|
||||
}
|
||||
for propName, prop := range schema.PatternProperties {
|
||||
res.Merge(d.validateDefaultValueSchemaAgainstSchema(path+"."+propName, in, &prop))
|
||||
res.Merge(d.validateDefaultValueSchemaAgainstSchema(path+"."+propName, in, &prop)) //#nosec
|
||||
}
|
||||
if schema.AdditionalProperties != nil && schema.AdditionalProperties.Schema != nil {
|
||||
res.Merge(d.validateDefaultValueSchemaAgainstSchema(fmt.Sprintf("%s.additionalProperties", path), in, schema.AdditionalProperties.Schema))
|
||||
}
|
||||
if schema.AllOf != nil {
|
||||
for i, aoSch := range schema.AllOf {
|
||||
res.Merge(d.validateDefaultValueSchemaAgainstSchema(fmt.Sprintf("%s.allOf[%d]", path, i), in, &aoSch))
|
||||
res.Merge(d.validateDefaultValueSchemaAgainstSchema(fmt.Sprintf("%s.allOf[%d]", path, i), in, &aoSch)) //#nosec
|
||||
}
|
||||
}
|
||||
return res
|
||||
|
||||
22
vendor/github.com/go-openapi/validate/example_validator.go
generated
vendored
22
vendor/github.com/go-openapi/validate/example_validator.go
generated
vendored
@@ -68,7 +68,7 @@ func (ex *exampleValidator) validateExampleValueValidAgainstSchema() *Result {
|
||||
res := new(Result)
|
||||
s := ex.SpecValidator
|
||||
|
||||
for method, pathItem := range s.analyzer.Operations() {
|
||||
for method, pathItem := range s.expandedAnalyzer().Operations() {
|
||||
for path, op := range pathItem {
|
||||
// parameters
|
||||
for _, param := range paramHelp.safeExpandedParamsFor(path, method, op.ID, res, s) {
|
||||
@@ -83,7 +83,7 @@ func (ex *exampleValidator) validateExampleValueValidAgainstSchema() *Result {
|
||||
// default values provided must validate against their inline definition (no explicit schema)
|
||||
if param.Example != nil && param.Schema == nil {
|
||||
// check param default value is valid
|
||||
red := NewParamValidator(¶m, s.KnownFormats).Validate(param.Example)
|
||||
red := NewParamValidator(¶m, s.KnownFormats).Validate(param.Example) //#nosec
|
||||
if red.HasErrorsOrWarnings() {
|
||||
res.AddWarnings(exampleValueDoesNotValidateMsg(param.Name, param.In))
|
||||
res.MergeAsWarnings(red)
|
||||
@@ -92,7 +92,7 @@ func (ex *exampleValidator) validateExampleValueValidAgainstSchema() *Result {
|
||||
|
||||
// Recursively follows Items and Schemas
|
||||
if param.Items != nil {
|
||||
red := ex.validateExampleValueItemsAgainstSchema(param.Name, param.In, ¶m, param.Items)
|
||||
red := ex.validateExampleValueItemsAgainstSchema(param.Name, param.In, ¶m, param.Items) //#nosec
|
||||
if red.HasErrorsOrWarnings() {
|
||||
res.AddWarnings(exampleValueItemsDoesNotValidateMsg(param.Name, param.In))
|
||||
res.Merge(red)
|
||||
@@ -117,7 +117,7 @@ func (ex *exampleValidator) validateExampleValueValidAgainstSchema() *Result {
|
||||
// Same constraint on regular Responses
|
||||
if op.Responses.StatusCodeResponses != nil { // Safeguard
|
||||
for code, r := range op.Responses.StatusCodeResponses {
|
||||
res.Merge(ex.validateExampleInResponse(&r, "response", path, code, op.ID))
|
||||
res.Merge(ex.validateExampleInResponse(&r, "response", path, code, op.ID)) //#nosec
|
||||
}
|
||||
}
|
||||
} else if op.ID != "" {
|
||||
@@ -130,7 +130,7 @@ func (ex *exampleValidator) validateExampleValueValidAgainstSchema() *Result {
|
||||
// reset explored schemas to get depth-first recursive-proof exploration
|
||||
ex.resetVisited()
|
||||
for nm, sch := range s.spec.Spec().Definitions {
|
||||
res.Merge(ex.validateExampleValueSchemaAgainstSchema(fmt.Sprintf("definitions.%s", nm), "body", &sch))
|
||||
res.Merge(ex.validateExampleValueSchemaAgainstSchema(fmt.Sprintf("definitions.%s", nm), "body", &sch)) //#nosec
|
||||
}
|
||||
}
|
||||
return res
|
||||
@@ -153,7 +153,7 @@ func (ex *exampleValidator) validateExampleInResponse(resp *spec.Response, respo
|
||||
ex.resetVisited()
|
||||
|
||||
if h.Example != nil {
|
||||
red := NewHeaderValidator(nm, &h, s.KnownFormats).Validate(h.Example)
|
||||
red := NewHeaderValidator(nm, &h, s.KnownFormats).Validate(h.Example) //#nosec
|
||||
if red.HasErrorsOrWarnings() {
|
||||
res.AddWarnings(exampleValueHeaderDoesNotValidateMsg(operationID, nm, responseName))
|
||||
res.MergeAsWarnings(red)
|
||||
@@ -162,7 +162,7 @@ func (ex *exampleValidator) validateExampleInResponse(resp *spec.Response, respo
|
||||
|
||||
// Headers have inline definition, like params
|
||||
if h.Items != nil {
|
||||
red := ex.validateExampleValueItemsAgainstSchema(nm, "header", &h, h.Items)
|
||||
red := ex.validateExampleValueItemsAgainstSchema(nm, "header", &h, h.Items) //#nosec
|
||||
if red.HasErrorsOrWarnings() {
|
||||
res.AddWarnings(exampleValueHeaderItemsDoesNotValidateMsg(operationID, nm, responseName))
|
||||
res.MergeAsWarnings(red)
|
||||
@@ -222,7 +222,7 @@ func (ex *exampleValidator) validateExampleValueSchemaAgainstSchema(path, in str
|
||||
// Multiple schemas in items
|
||||
if schema.Items.Schemas != nil { // Safeguard
|
||||
for i, sch := range schema.Items.Schemas {
|
||||
res.Merge(ex.validateExampleValueSchemaAgainstSchema(fmt.Sprintf("%s.items[%d].example", path, i), in, &sch))
|
||||
res.Merge(ex.validateExampleValueSchemaAgainstSchema(fmt.Sprintf("%s.items[%d].example", path, i), in, &sch)) //#nosec
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -234,17 +234,17 @@ func (ex *exampleValidator) validateExampleValueSchemaAgainstSchema(path, in str
|
||||
res.Merge(ex.validateExampleValueSchemaAgainstSchema(fmt.Sprintf("%s.additionalItems", path), in, schema.AdditionalItems.Schema))
|
||||
}
|
||||
for propName, prop := range schema.Properties {
|
||||
res.Merge(ex.validateExampleValueSchemaAgainstSchema(path+"."+propName, in, &prop))
|
||||
res.Merge(ex.validateExampleValueSchemaAgainstSchema(path+"."+propName, in, &prop)) //#nosec
|
||||
}
|
||||
for propName, prop := range schema.PatternProperties {
|
||||
res.Merge(ex.validateExampleValueSchemaAgainstSchema(path+"."+propName, in, &prop))
|
||||
res.Merge(ex.validateExampleValueSchemaAgainstSchema(path+"."+propName, in, &prop)) //#nosec
|
||||
}
|
||||
if schema.AdditionalProperties != nil && schema.AdditionalProperties.Schema != nil {
|
||||
res.Merge(ex.validateExampleValueSchemaAgainstSchema(fmt.Sprintf("%s.additionalProperties", path), in, schema.AdditionalProperties.Schema))
|
||||
}
|
||||
if schema.AllOf != nil {
|
||||
for i, aoSch := range schema.AllOf {
|
||||
res.Merge(ex.validateExampleValueSchemaAgainstSchema(fmt.Sprintf("%s.allOf[%d]", path, i), in, &aoSch))
|
||||
res.Merge(ex.validateExampleValueSchemaAgainstSchema(fmt.Sprintf("%s.allOf[%d]", path, i), in, &aoSch)) //#nosec
|
||||
}
|
||||
}
|
||||
return res
|
||||
|
||||
16
vendor/github.com/go-openapi/validate/helpers.go
generated
vendored
16
vendor/github.com/go-openapi/validate/helpers.go
generated
vendored
@@ -47,7 +47,7 @@ const (
|
||||
jsonProperties = "properties"
|
||||
jsonItems = "items"
|
||||
jsonType = "type"
|
||||
//jsonSchema = "schema"
|
||||
// jsonSchema = "schema"
|
||||
jsonDefault = "default"
|
||||
)
|
||||
|
||||
@@ -56,7 +56,7 @@ const (
|
||||
stringFormatDateTime = "date-time"
|
||||
stringFormatPassword = "password"
|
||||
stringFormatByte = "byte"
|
||||
//stringFormatBinary = "binary"
|
||||
// stringFormatBinary = "binary"
|
||||
stringFormatCreditCard = "creditcard"
|
||||
stringFormatDuration = "duration"
|
||||
stringFormatEmail = "email"
|
||||
@@ -165,7 +165,7 @@ func (h *valueHelper) asInt64(val interface{}) int64 {
|
||||
case reflect.Float32, reflect.Float64:
|
||||
return int64(v.Float())
|
||||
default:
|
||||
//panic("Non numeric value in asInt64()")
|
||||
// panic("Non numeric value in asInt64()")
|
||||
return 0
|
||||
}
|
||||
}
|
||||
@@ -182,7 +182,7 @@ func (h *valueHelper) asUint64(val interface{}) uint64 {
|
||||
case reflect.Float32, reflect.Float64:
|
||||
return uint64(v.Float())
|
||||
default:
|
||||
//panic("Non numeric value in asUint64()")
|
||||
// panic("Non numeric value in asUint64()")
|
||||
return 0
|
||||
}
|
||||
}
|
||||
@@ -200,7 +200,7 @@ func (h *valueHelper) asFloat64(val interface{}) float64 {
|
||||
case reflect.Float32, reflect.Float64:
|
||||
return v.Float()
|
||||
default:
|
||||
//panic("Non numeric value in asFloat64()")
|
||||
// panic("Non numeric value in asFloat64()")
|
||||
return 0
|
||||
}
|
||||
}
|
||||
@@ -210,12 +210,12 @@ type paramHelper struct {
|
||||
}
|
||||
|
||||
func (h *paramHelper) safeExpandedParamsFor(path, method, operationID string, res *Result, s *SpecValidator) (params []spec.Parameter) {
|
||||
operation, ok := s.analyzer.OperationFor(method, path)
|
||||
operation, ok := s.expandedAnalyzer().OperationFor(method, path)
|
||||
if ok {
|
||||
// expand parameters first if necessary
|
||||
resolvedParams := []spec.Parameter{}
|
||||
for _, ppr := range operation.Parameters {
|
||||
resolvedParam, red := h.resolveParam(path, method, operationID, &ppr, s)
|
||||
resolvedParam, red := h.resolveParam(path, method, operationID, &ppr, s) //#nosec
|
||||
res.Merge(red)
|
||||
if resolvedParam != nil {
|
||||
resolvedParams = append(resolvedParams, *resolvedParam)
|
||||
@@ -224,7 +224,7 @@ func (h *paramHelper) safeExpandedParamsFor(path, method, operationID string, re
|
||||
// remove params with invalid expansion from Slice
|
||||
operation.Parameters = resolvedParams
|
||||
|
||||
for _, ppr := range s.analyzer.SafeParamsFor(method, path,
|
||||
for _, ppr := range s.expandedAnalyzer().SafeParamsFor(method, path,
|
||||
func(p spec.Parameter, err error) bool {
|
||||
// since params have already been expanded, there are few causes for error
|
||||
res.AddErrors(someParametersBrokenMsg(path, method, operationID))
|
||||
|
||||
14
vendor/github.com/go-openapi/validate/object_validator.go
generated
vendored
14
vendor/github.com/go-openapi/validate/object_validator.go
generated
vendored
@@ -71,8 +71,8 @@ func (o *objectValidator) checkArrayMustHaveItems(res *Result, val map[string]in
|
||||
// with pure jsonschema draft 4, one may have arrays with undefined items (i.e. any type).
|
||||
if t, typeFound := val[jsonType]; typeFound {
|
||||
if tpe, ok := t.(string); ok && tpe == arrayType {
|
||||
if _, itemsKeyFound := val[jsonItems]; !itemsKeyFound {
|
||||
res.AddErrors(errors.Required(jsonItems, o.Path))
|
||||
if item, itemsKeyFound := val[jsonItems]; !itemsKeyFound {
|
||||
res.AddErrors(errors.Required(jsonItems, o.Path, item))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,7 +88,7 @@ func (o *objectValidator) checkItemsMustBeTypeArray(res *Result, val map[string]
|
||||
}
|
||||
} else {
|
||||
// there is no type
|
||||
res.AddErrors(errors.Required(jsonType, o.Path))
|
||||
res.AddErrors(errors.Required(jsonType, o.Path, t))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -227,8 +227,8 @@ func (o *objectValidator) Validate(data interface{}) *Result {
|
||||
// Check required properties
|
||||
if len(o.Required) > 0 {
|
||||
for _, k := range o.Required {
|
||||
if _, ok := val[k]; !ok && !createdFromDefaults[k] {
|
||||
res.AddErrors(errors.Required(o.Path+"."+k, o.In))
|
||||
if v, ok := val[k]; !ok && !createdFromDefaults[k] {
|
||||
res.AddErrors(errors.Required(o.Path+"."+k, o.In, v))
|
||||
continue
|
||||
}
|
||||
}
|
||||
@@ -271,9 +271,9 @@ func (o *objectValidator) validatePatternProperty(key string, value interface{},
|
||||
|
||||
// BUG(fredbi): can't get to here. Should remove dead code (commented out).
|
||||
|
||||
//if succeededOnce {
|
||||
// if succeededOnce {
|
||||
// result.Inc()
|
||||
//}
|
||||
// }
|
||||
|
||||
return matched, succeededOnce, patterns
|
||||
}
|
||||
|
||||
2
vendor/github.com/go-openapi/validate/rexp.go
generated
vendored
2
vendor/github.com/go-openapi/validate/rexp.go
generated
vendored
@@ -23,7 +23,7 @@ import (
|
||||
// Cache for compiled regular expressions
|
||||
var (
|
||||
cacheMutex = &sync.Mutex{}
|
||||
reDict = atomic.Value{} //map[string]*re.Regexp
|
||||
reDict = atomic.Value{} // map[string]*re.Regexp
|
||||
)
|
||||
|
||||
func compileRegexp(pattern string) (*re.Regexp, error) {
|
||||
|
||||
2
vendor/github.com/go-openapi/validate/schema.go
generated
vendored
2
vendor/github.com/go-openapi/validate/schema.go
generated
vendored
@@ -28,7 +28,7 @@ var (
|
||||
specSchemaType = reflect.TypeOf(&spec.Schema{})
|
||||
specParameterType = reflect.TypeOf(&spec.Parameter{})
|
||||
specHeaderType = reflect.TypeOf(&spec.Header{})
|
||||
//specItemsType = reflect.TypeOf(&spec.Items{})
|
||||
// specItemsType = reflect.TypeOf(&spec.Items{})
|
||||
)
|
||||
|
||||
// SchemaValidator validates data against a JSON schema
|
||||
|
||||
4
vendor/github.com/go-openapi/validate/schema_props.go
generated
vendored
4
vendor/github.com/go-openapi/validate/schema_props.go
generated
vendored
@@ -163,7 +163,7 @@ func (s *schemaPropsValidator) Validate(data interface{}) *Result {
|
||||
}
|
||||
|
||||
if validated != 1 {
|
||||
additionalMsg := ""
|
||||
var additionalMsg string
|
||||
if validated == 0 {
|
||||
additionalMsg = "Found none valid"
|
||||
} else {
|
||||
@@ -187,7 +187,7 @@ func (s *schemaPropsValidator) Validate(data interface{}) *Result {
|
||||
result := allOfSchema.Validate(data)
|
||||
// We keep inner IMPORTANT! errors no matter what MatchCount tells us
|
||||
keepResultAllOf.Merge(result.keepRelevantErrors())
|
||||
//keepResultAllOf.Merge(result)
|
||||
// keepResultAllOf.Merge(result)
|
||||
if result.IsValid() {
|
||||
validated++
|
||||
}
|
||||
|
||||
19
vendor/github.com/go-openapi/validate/spec.go
generated
vendored
19
vendor/github.com/go-openapi/validate/spec.go
generated
vendored
@@ -141,7 +141,7 @@ func (s *SpecValidator) Validate(data interface{}) (*Result, *Result) {
|
||||
|
||||
errs.Merge(s.validateNonEmptyPathParamNames())
|
||||
|
||||
//errs.Merge(s.validateRefNoSibling()) // warning only
|
||||
// errs.Merge(s.validateRefNoSibling()) // warning only
|
||||
errs.Merge(s.validateReferenced()) // warning only
|
||||
|
||||
return errs, warnings
|
||||
@@ -543,7 +543,7 @@ DEFINITIONS:
|
||||
for d, schema := range s.spec.Spec().Definitions {
|
||||
if schema.Required != nil { // Safeguard
|
||||
for _, pn := range schema.Required {
|
||||
red := s.validateRequiredProperties(pn, d, &schema)
|
||||
red := s.validateRequiredProperties(pn, d, &schema) //#nosec
|
||||
res.Merge(red)
|
||||
if !red.IsValid() && !s.Options.ContinueOnErrors {
|
||||
break DEFINITIONS // there is an error, let's stop that bleeding
|
||||
@@ -624,7 +624,7 @@ func (s *SpecValidator) validateParameters() *Result {
|
||||
// - path param must be required
|
||||
res := new(Result)
|
||||
rexGarbledPathSegment := mustCompileRegexp(`.*[{}\s]+.*`)
|
||||
for method, pi := range s.analyzer.Operations() {
|
||||
for method, pi := range s.expandedAnalyzer().Operations() {
|
||||
methodPaths := make(map[string]map[string]string)
|
||||
for path, op := range pi {
|
||||
pathToAdd := pathHelp.stripParametersInPath(path)
|
||||
@@ -647,7 +647,7 @@ func (s *SpecValidator) validateParameters() *Result {
|
||||
if _, found := methodPaths[method]; !found {
|
||||
methodPaths[method] = map[string]string{}
|
||||
}
|
||||
methodPaths[method][pathToAdd] = path //Original non stripped path
|
||||
methodPaths[method][pathToAdd] = path // Original non stripped path
|
||||
|
||||
}
|
||||
|
||||
@@ -773,7 +773,7 @@ func (s *SpecValidator) checkUniqueParams(path, method string, op *spec.Operatio
|
||||
if op.Parameters != nil { // Safeguard
|
||||
for _, ppr := range op.Parameters {
|
||||
var ok bool
|
||||
pr, red := paramHelp.resolveParam(path, method, op.ID, &ppr, s)
|
||||
pr, red := paramHelp.resolveParam(path, method, op.ID, &ppr, s) //#nosec
|
||||
res.Merge(red)
|
||||
|
||||
if pr != nil && pr.Name != "" { // params with empty name does no participate the check
|
||||
@@ -793,3 +793,12 @@ func (s *SpecValidator) checkUniqueParams(path, method string, op *spec.Operatio
|
||||
func (s *SpecValidator) SetContinueOnErrors(c bool) {
|
||||
s.Options.ContinueOnErrors = c
|
||||
}
|
||||
|
||||
// expandedAnalyzer returns expanded.Analyzer when it is available.
|
||||
// otherwise just analyzer.
|
||||
func (s *SpecValidator) expandedAnalyzer() *analysis.Spec {
|
||||
if s.expanded != nil && s.expanded.Analyzer != nil {
|
||||
return s.expanded.Analyzer
|
||||
}
|
||||
return s.analyzer
|
||||
}
|
||||
|
||||
4
vendor/github.com/go-openapi/validate/spec_messages.go
generated
vendored
4
vendor/github.com/go-openapi/validate/spec_messages.go
generated
vendored
@@ -349,9 +349,9 @@ func parameterValidationTypeMismatchMsg(param, path, typ string) errors.Error {
|
||||
}
|
||||
|
||||
// disabled
|
||||
//func invalidResponseDefinitionAsSchemaMsg(path, method string) errors.Error {
|
||||
// func invalidResponseDefinitionAsSchemaMsg(path, method string) errors.Error {
|
||||
// return errors.New(errors.CompositeErrorCode, InvalidResponseDefinitionAsSchemaError, path, method)
|
||||
//}
|
||||
// }
|
||||
func someParametersBrokenMsg(path, method, operationID string) errors.Error {
|
||||
return errors.New(errors.CompositeErrorCode, SomeParametersBrokenError, path, method, operationID)
|
||||
}
|
||||
|
||||
5
vendor/github.com/go-openapi/validate/type.go
generated
vendored
5
vendor/github.com/go-openapi/validate/type.go
generated
vendored
@@ -19,7 +19,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/spec"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
@@ -48,7 +47,7 @@ func (t *typeValidator) schemaInfoForType(data interface{}) (string, string) {
|
||||
return stringType, stringFormatDateTime
|
||||
case strfmt.Duration, *strfmt.Duration:
|
||||
return stringType, stringFormatDuration
|
||||
case runtime.File, *runtime.File:
|
||||
case swag.File, *swag.File:
|
||||
return fileType, ""
|
||||
case strfmt.Email, *strfmt.Email:
|
||||
return stringType, stringFormatEmail
|
||||
@@ -137,7 +136,7 @@ func (t *typeValidator) Applies(source interface{}, kind reflect.Kind) bool {
|
||||
func (t *typeValidator) Validate(data interface{}) *Result {
|
||||
result := new(Result)
|
||||
result.Inc()
|
||||
if data == nil || reflect.DeepEqual(reflect.Zero(reflect.TypeOf(data)), reflect.ValueOf(data)) {
|
||||
if data == nil {
|
||||
// nil or zero value for the passed structure require Type: null
|
||||
if len(t.Type) > 0 && !t.Type.Contains(nullType) && !t.Nullable { // TODO: if a property is not required it also passes this
|
||||
return errorHelp.sErr(errors.InvalidType(t.Path, t.In, strings.Join(t.Type, ","), nullType))
|
||||
|
||||
1
vendor/github.com/go-openapi/validate/validator.go
generated
vendored
1
vendor/github.com/go-openapi/validate/validator.go
generated
vendored
@@ -532,7 +532,6 @@ func (n *numberValidator) Validate(val interface{}) *Result {
|
||||
// Is the provided value within the range of the specified numeric type and format?
|
||||
res.AddErrors(IsValueValidAgainstRange(val, n.Type, n.Format, "Checked", n.Path))
|
||||
|
||||
// nolint: dupl
|
||||
if n.MultipleOf != nil {
|
||||
// Is the constraint specifier within the range of the specific numeric type and format?
|
||||
resMultiple.AddErrors(IsValueValidAgainstRange(*n.MultipleOf, n.Type, n.Format, "MultipleOf", n.Path))
|
||||
|
||||
64
vendor/github.com/go-openapi/validate/values.go
generated
vendored
64
vendor/github.com/go-openapi/validate/values.go
generated
vendored
@@ -15,6 +15,7 @@
|
||||
package validate
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
@@ -85,7 +86,7 @@ func convertEnumCaseStringKind(value interface{}, caseSensitive bool) *string {
|
||||
// MinItems validates that there are at least n items in a slice
|
||||
func MinItems(path, in string, size, min int64) *errors.Validation {
|
||||
if size < min {
|
||||
return errors.TooFewItems(path, in, min)
|
||||
return errors.TooFewItems(path, in, min, size)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -93,7 +94,7 @@ func MinItems(path, in string, size, min int64) *errors.Validation {
|
||||
// MaxItems validates that there are at most n items in a slice
|
||||
func MaxItems(path, in string, size, max int64) *errors.Validation {
|
||||
if size > max {
|
||||
return errors.TooManyItems(path, in, max)
|
||||
return errors.TooManyItems(path, in, max, size)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -121,7 +122,7 @@ func UniqueItems(path, in string, data interface{}) *errors.Validation {
|
||||
func MinLength(path, in, data string, minLength int64) *errors.Validation {
|
||||
strLen := int64(utf8.RuneCount([]byte(data)))
|
||||
if strLen < minLength {
|
||||
return errors.TooShort(path, in, minLength)
|
||||
return errors.TooShort(path, in, minLength, data)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -130,27 +131,48 @@ func MinLength(path, in, data string, minLength int64) *errors.Validation {
|
||||
func MaxLength(path, in, data string, maxLength int64) *errors.Validation {
|
||||
strLen := int64(utf8.RuneCount([]byte(data)))
|
||||
if strLen > maxLength {
|
||||
return errors.TooLong(path, in, maxLength)
|
||||
return errors.TooLong(path, in, maxLength, data)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ReadOnly validates an interface for readonly
|
||||
func ReadOnly(ctx context.Context, path, in string, data interface{}) *errors.Validation {
|
||||
|
||||
// read only is only validated when operationType is request
|
||||
if op := extractOperationType(ctx); op != request {
|
||||
return nil
|
||||
}
|
||||
|
||||
// data must be of zero value of its type
|
||||
val := reflect.ValueOf(data)
|
||||
if val.IsValid() {
|
||||
if reflect.DeepEqual(reflect.Zero(val.Type()).Interface(), val.Interface()) {
|
||||
return nil
|
||||
}
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return errors.ReadOnly(path, in, data)
|
||||
}
|
||||
|
||||
// Required validates an interface for requiredness
|
||||
func Required(path, in string, data interface{}) *errors.Validation {
|
||||
val := reflect.ValueOf(data)
|
||||
if val.IsValid() {
|
||||
if reflect.DeepEqual(reflect.Zero(val.Type()).Interface(), val.Interface()) {
|
||||
return errors.Required(path, in)
|
||||
return errors.Required(path, in, data)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return errors.Required(path, in)
|
||||
return errors.Required(path, in, data)
|
||||
}
|
||||
|
||||
// RequiredString validates a string for requiredness
|
||||
func RequiredString(path, in, data string) *errors.Validation {
|
||||
if data == "" {
|
||||
return errors.Required(path, in)
|
||||
return errors.Required(path, in, data)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -158,7 +180,7 @@ func RequiredString(path, in, data string) *errors.Validation {
|
||||
// RequiredNumber validates a number for requiredness
|
||||
func RequiredNumber(path, in string, data float64) *errors.Validation {
|
||||
if data == 0 {
|
||||
return errors.Required(path, in)
|
||||
return errors.Required(path, in, data)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -167,10 +189,10 @@ func RequiredNumber(path, in string, data float64) *errors.Validation {
|
||||
func Pattern(path, in, data, pattern string) *errors.Validation {
|
||||
re, err := compileRegexp(pattern)
|
||||
if err != nil {
|
||||
return errors.FailedPattern(path, in, fmt.Sprintf("%s, but pattern is invalid: %s", pattern, err.Error()))
|
||||
return errors.FailedPattern(path, in, fmt.Sprintf("%s, but pattern is invalid: %s", pattern, err.Error()), data)
|
||||
}
|
||||
if !re.MatchString(data) {
|
||||
return errors.FailedPattern(path, in, pattern)
|
||||
return errors.FailedPattern(path, in, pattern, data)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -178,7 +200,7 @@ func Pattern(path, in, data, pattern string) *errors.Validation {
|
||||
// MaximumInt validates if a number is smaller than a given maximum
|
||||
func MaximumInt(path, in string, data, max int64, exclusive bool) *errors.Validation {
|
||||
if (!exclusive && data > max) || (exclusive && data >= max) {
|
||||
return errors.ExceedsMaximumInt(path, in, max, exclusive)
|
||||
return errors.ExceedsMaximumInt(path, in, max, exclusive, data)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -186,7 +208,7 @@ func MaximumInt(path, in string, data, max int64, exclusive bool) *errors.Valida
|
||||
// MaximumUint validates if a number is smaller than a given maximum
|
||||
func MaximumUint(path, in string, data, max uint64, exclusive bool) *errors.Validation {
|
||||
if (!exclusive && data > max) || (exclusive && data >= max) {
|
||||
return errors.ExceedsMaximumUint(path, in, max, exclusive)
|
||||
return errors.ExceedsMaximumUint(path, in, max, exclusive, data)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -194,7 +216,7 @@ func MaximumUint(path, in string, data, max uint64, exclusive bool) *errors.Vali
|
||||
// Maximum validates if a number is smaller than a given maximum
|
||||
func Maximum(path, in string, data, max float64, exclusive bool) *errors.Validation {
|
||||
if (!exclusive && data > max) || (exclusive && data >= max) {
|
||||
return errors.ExceedsMaximum(path, in, max, exclusive)
|
||||
return errors.ExceedsMaximum(path, in, max, exclusive, data)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -202,7 +224,7 @@ func Maximum(path, in string, data, max float64, exclusive bool) *errors.Validat
|
||||
// Minimum validates if a number is smaller than a given minimum
|
||||
func Minimum(path, in string, data, min float64, exclusive bool) *errors.Validation {
|
||||
if (!exclusive && data < min) || (exclusive && data <= min) {
|
||||
return errors.ExceedsMinimum(path, in, min, exclusive)
|
||||
return errors.ExceedsMinimum(path, in, min, exclusive, data)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -210,7 +232,7 @@ func Minimum(path, in string, data, min float64, exclusive bool) *errors.Validat
|
||||
// MinimumInt validates if a number is smaller than a given minimum
|
||||
func MinimumInt(path, in string, data, min int64, exclusive bool) *errors.Validation {
|
||||
if (!exclusive && data < min) || (exclusive && data <= min) {
|
||||
return errors.ExceedsMinimumInt(path, in, min, exclusive)
|
||||
return errors.ExceedsMinimumInt(path, in, min, exclusive, data)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -218,7 +240,7 @@ func MinimumInt(path, in string, data, min int64, exclusive bool) *errors.Valida
|
||||
// MinimumUint validates if a number is smaller than a given minimum
|
||||
func MinimumUint(path, in string, data, min uint64, exclusive bool) *errors.Validation {
|
||||
if (!exclusive && data < min) || (exclusive && data <= min) {
|
||||
return errors.ExceedsMinimumUint(path, in, min, exclusive)
|
||||
return errors.ExceedsMinimumUint(path, in, min, exclusive, data)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -236,7 +258,7 @@ func MultipleOf(path, in string, data, factor float64) *errors.Validation {
|
||||
mult = data / factor
|
||||
}
|
||||
if !swag.IsFloat64AJSONInteger(mult) {
|
||||
return errors.NotMultipleOf(path, in, factor)
|
||||
return errors.NotMultipleOf(path, in, factor, data)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -249,7 +271,7 @@ func MultipleOfInt(path, in string, data int64, factor int64) *errors.Validation
|
||||
}
|
||||
mult := data / factor
|
||||
if mult*factor != data {
|
||||
return errors.NotMultipleOf(path, in, factor)
|
||||
return errors.NotMultipleOf(path, in, factor, data)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -258,7 +280,7 @@ func MultipleOfInt(path, in string, data int64, factor int64) *errors.Validation
|
||||
func MultipleOfUint(path, in string, data, factor uint64) *errors.Validation {
|
||||
mult := data / factor
|
||||
if mult*factor != data {
|
||||
return errors.NotMultipleOf(path, in, factor)
|
||||
return errors.NotMultipleOf(path, in, factor, data)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -296,7 +318,7 @@ func MaximumNativeType(path, in string, val interface{}, max float64, exclusive
|
||||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
|
||||
value := valueHelp.asUint64(val)
|
||||
if max < 0 {
|
||||
return errors.ExceedsMaximum(path, in, max, exclusive)
|
||||
return errors.ExceedsMaximum(path, in, max, exclusive, val)
|
||||
}
|
||||
return MaximumUint(path, in, value, uint64(max), exclusive)
|
||||
case reflect.Float32, reflect.Float64:
|
||||
@@ -372,7 +394,7 @@ func IsValueValidAgainstRange(val interface{}, typeName, format, prefix, path st
|
||||
kind := reflect.ValueOf(val).Type().Kind()
|
||||
|
||||
// What is the string representation of val
|
||||
stringRep := ""
|
||||
var stringRep string
|
||||
switch kind {
|
||||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
|
||||
stringRep = swag.FormatUint64(valueHelp.asUint64(val))
|
||||
|
||||
Reference in New Issue
Block a user