123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355 |
- package validate
- import (
- "net/http"
- "github.com/go-openapi/errors"
- )
- const (
-
- ArrayRequiresItemsError = "%s for %q is a collection without an element type (array requires items definition)"
-
- ArrayInParamRequiresItemsError = "param %q for %q is a collection without an element type (array requires item definition)"
-
- ArrayInHeaderRequiresItemsError = "header %q for %q is a collection without an element type (array requires items definition)"
-
- BothFormDataAndBodyError = "operation %q has both formData and body parameters. Only one such In: type may be used for a given operation"
-
- CannotResolveReferenceError = "could not resolve reference in %s to $ref %s: %v"
-
- CircularAncestryDefinitionError = "definition %q has circular ancestry: %v"
-
- DefaultValueDoesNotValidateError = "default value for %s in %s does not validate its schema"
-
- DefaultValueItemsDoesNotValidateError = "default value for %s.items in %s does not validate its schema"
-
- DefaultValueHeaderDoesNotValidateError = "in operation %q, default value in header %s for %s does not validate its schema"
-
- DefaultValueHeaderItemsDoesNotValidateError = "in operation %q, default value in header.items %s for %s does not validate its schema"
-
- DefaultValueInDoesNotValidateError = "in operation %q, default value in %s does not validate its schema"
-
- DuplicateParamNameError = "duplicate parameter name %q for %q in operation %q"
-
- DuplicatePropertiesError = "definition %q contains duplicate properties: %v"
-
- ExampleValueDoesNotValidateError = "example value for %s in %s does not validate its schema"
-
- ExampleValueItemsDoesNotValidateError = "example value for %s.items in %s does not validate its schema"
-
- ExampleValueHeaderDoesNotValidateError = "in operation %q, example value in header %s for %s does not validate its schema"
-
- ExampleValueHeaderItemsDoesNotValidateError = "in operation %q, example value in header.items %s for %s does not validate its schema"
-
- ExampleValueInDoesNotValidateError = "in operation %q, example value in %s does not validate its schema"
-
- EmptyPathParameterError = "%q contains an empty path parameter"
-
- InvalidDocumentError = "spec validator can only validate spec.Document objects"
-
- InvalidItemsPatternError = "%s for %q has invalid items pattern: %q"
-
- InvalidParameterDefinitionError = "invalid definition for parameter %s in %s in operation %q"
-
-
- InvalidParameterDefinitionAsSchemaError = "invalid definition as Schema for parameter %s in %s in operation %q"
-
- InvalidPatternError = "pattern %q is invalid in %s"
-
- InvalidPatternInError = "%s in %s has invalid pattern: %q"
-
- InvalidPatternInHeaderError = "in operation %q, header %s for %s has invalid pattern %q: %v"
-
- InvalidPatternInParamError = "operation %q has invalid pattern in param %q: %q"
-
- InvalidReferenceError = "invalid ref %q"
-
-
- InvalidResponseDefinitionAsSchemaError = "invalid definition as Schema for response %s in %s"
-
- MultipleBodyParamError = "operation %q has more than 1 body param: %v"
-
- NonUniqueOperationIDError = "%q is defined %d times"
-
- NoParameterInPathError = "path param %q has no parameter definition"
-
- NoValidPathErrorOrWarning = "spec has no valid path defined"
-
- NoValidResponseError = "operation %q has no valid response"
-
- PathOverlapError = "path %s overlaps with %s"
-
- PathParamNotInPathError = "path param %q is not present in path %q"
-
- PathParamNotUniqueError = "params in path %q must be unique: %q conflicts with %q"
-
- PathParamRequiredError = "in operation %q,path param %q must be declared as required"
-
- RefNotAllowedInHeaderError = "IMPORTANT!in %q: $ref are not allowed in headers. In context for header %q%s"
-
- RequiredButNotDefinedError = "%q is present in required but not defined as property in definition %q"
-
- SomeParametersBrokenError = "some parameters definitions are broken in %q.%s. Cannot carry on full checks on parameters for operation %s"
-
- UnresolvedReferencesError = "some references could not be resolved in spec. First found: %v"
- )
- const (
-
- ExamplesWithoutSchemaWarning = "Examples provided without schema in operation %q, %s"
-
-
- ExamplesMimeNotSupportedWarning = "No validation attempt for examples for media types other than application/json, in operation %q, %s"
-
- PathParamGarbledWarning = "in path %q, param %q contains {,} or white space. Albeit not stricly illegal, this is probably no what you want"
-
- PathStrippedParamGarbledWarning = "path stripped from path parameters %s contains {,} or white space. This is probably no what you want."
-
- ReadOnlyAndRequiredWarning = "Required property %s in %q should not be marked as both required and readOnly"
-
-
- RefShouldNotHaveSiblingsWarning = "$ref property should have no sibling in %q.%s"
-
- RequiredHasDefaultWarning = "%s in %s has a default value and is required as parameter"
-
- UnusedDefinitionWarning = "definition %q is not used anywhere"
-
- UnusedParamWarning = "parameter %q is not used anywhere"
-
- UnusedResponseWarning = "response %q is not used anywhere"
- )
- const (
-
- InternalErrorCode = http.StatusInternalServerError
-
- NotFoundErrorCode = http.StatusNotFound
- )
- func invalidDocumentMsg() errors.Error {
- return errors.New(InternalErrorCode, InvalidDocumentError)
- }
- func invalidRefMsg(path string) errors.Error {
- return errors.New(NotFoundErrorCode, InvalidReferenceError, path)
- }
- func unresolvedReferencesMsg(err error) errors.Error {
- return errors.New(errors.CompositeErrorCode, UnresolvedReferencesError, err)
- }
- func noValidPathMsg() errors.Error {
- return errors.New(errors.CompositeErrorCode, NoValidPathErrorOrWarning)
- }
- func emptyPathParameterMsg(path string) errors.Error {
- return errors.New(errors.CompositeErrorCode, EmptyPathParameterError, path)
- }
- func nonUniqueOperationIDMsg(path string, i int) errors.Error {
- return errors.New(errors.CompositeErrorCode, NonUniqueOperationIDError, path, i)
- }
- func circularAncestryDefinitionMsg(path string, args interface{}) errors.Error {
- return errors.New(errors.CompositeErrorCode, CircularAncestryDefinitionError, path, args)
- }
- func duplicatePropertiesMsg(path string, args interface{}) errors.Error {
- return errors.New(errors.CompositeErrorCode, DuplicatePropertiesError, path, args)
- }
- func pathParamNotInPathMsg(path, param string) errors.Error {
- return errors.New(errors.CompositeErrorCode, PathParamNotInPathError, param, path)
- }
- func arrayRequiresItemsMsg(path, operation string) errors.Error {
- return errors.New(errors.CompositeErrorCode, ArrayRequiresItemsError, path, operation)
- }
- func arrayInParamRequiresItemsMsg(path, operation string) errors.Error {
- return errors.New(errors.CompositeErrorCode, ArrayInParamRequiresItemsError, path, operation)
- }
- func arrayInHeaderRequiresItemsMsg(path, operation string) errors.Error {
- return errors.New(errors.CompositeErrorCode, ArrayInHeaderRequiresItemsError, path, operation)
- }
- func invalidItemsPatternMsg(path, operation, pattern string) errors.Error {
- return errors.New(errors.CompositeErrorCode, InvalidItemsPatternError, path, operation, pattern)
- }
- func invalidPatternMsg(pattern, path string) errors.Error {
- return errors.New(errors.CompositeErrorCode, InvalidPatternError, pattern, path)
- }
- func requiredButNotDefinedMsg(path, definition string) errors.Error {
- return errors.New(errors.CompositeErrorCode, RequiredButNotDefinedError, path, definition)
- }
- func pathParamGarbledMsg(path, param string) errors.Error {
- return errors.New(errors.CompositeErrorCode, PathParamGarbledWarning, path, param)
- }
- func pathStrippedParamGarbledMsg(path string) errors.Error {
- return errors.New(errors.CompositeErrorCode, PathStrippedParamGarbledWarning, path)
- }
- func pathOverlapMsg(path, arg string) errors.Error {
- return errors.New(errors.CompositeErrorCode, PathOverlapError, path, arg)
- }
- func invalidPatternInParamMsg(operation, param, pattern string) errors.Error {
- return errors.New(errors.CompositeErrorCode, InvalidPatternInParamError, operation, param, pattern)
- }
- func pathParamRequiredMsg(operation, param string) errors.Error {
- return errors.New(errors.CompositeErrorCode, PathParamRequiredError, operation, param)
- }
- func bothFormDataAndBodyMsg(operation string) errors.Error {
- return errors.New(errors.CompositeErrorCode, BothFormDataAndBodyError, operation)
- }
- func multipleBodyParamMsg(operation string, args interface{}) errors.Error {
- return errors.New(errors.CompositeErrorCode, MultipleBodyParamError, operation, args)
- }
- func pathParamNotUniqueMsg(path, param, arg string) errors.Error {
- return errors.New(errors.CompositeErrorCode, PathParamNotUniqueError, path, param, arg)
- }
- func duplicateParamNameMsg(path, param, operation string) errors.Error {
- return errors.New(errors.CompositeErrorCode, DuplicateParamNameError, param, path, operation)
- }
- func unusedParamMsg(arg string) errors.Error {
- return errors.New(errors.CompositeErrorCode, UnusedParamWarning, arg)
- }
- func unusedDefinitionMsg(arg string) errors.Error {
- return errors.New(errors.CompositeErrorCode, UnusedDefinitionWarning, arg)
- }
- func unusedResponseMsg(arg string) errors.Error {
- return errors.New(errors.CompositeErrorCode, UnusedResponseWarning, arg)
- }
- func readOnlyAndRequiredMsg(path, param string) errors.Error {
- return errors.New(errors.CompositeErrorCode, ReadOnlyAndRequiredWarning, param, path)
- }
- func noParameterInPathMsg(param string) errors.Error {
- return errors.New(errors.CompositeErrorCode, NoParameterInPathError, param)
- }
- func requiredHasDefaultMsg(param, path string) errors.Error {
- return errors.New(errors.CompositeErrorCode, RequiredHasDefaultWarning, param, path)
- }
- func defaultValueDoesNotValidateMsg(param, path string) errors.Error {
- return errors.New(errors.CompositeErrorCode, DefaultValueDoesNotValidateError, param, path)
- }
- func defaultValueItemsDoesNotValidateMsg(param, path string) errors.Error {
- return errors.New(errors.CompositeErrorCode, DefaultValueItemsDoesNotValidateError, param, path)
- }
- func noValidResponseMsg(operation string) errors.Error {
- return errors.New(errors.CompositeErrorCode, NoValidResponseError, operation)
- }
- func defaultValueHeaderDoesNotValidateMsg(operation, header, path string) errors.Error {
- return errors.New(errors.CompositeErrorCode, DefaultValueHeaderDoesNotValidateError, operation, header, path)
- }
- func defaultValueHeaderItemsDoesNotValidateMsg(operation, header, path string) errors.Error {
- return errors.New(errors.CompositeErrorCode, DefaultValueHeaderItemsDoesNotValidateError, operation, header, path)
- }
- func invalidPatternInHeaderMsg(operation, header, path, pattern string, args interface{}) errors.Error {
- return errors.New(errors.CompositeErrorCode, InvalidPatternInHeaderError, operation, header, path, pattern, args)
- }
- func invalidPatternInMsg(path, in, pattern string) errors.Error {
- return errors.New(errors.CompositeErrorCode, InvalidPatternInError, path, in, pattern)
- }
- func defaultValueInDoesNotValidateMsg(operation, path string) errors.Error {
- return errors.New(errors.CompositeErrorCode, DefaultValueInDoesNotValidateError, operation, path)
- }
- func exampleValueDoesNotValidateMsg(param, path string) errors.Error {
- return errors.New(errors.CompositeErrorCode, ExampleValueDoesNotValidateError, param, path)
- }
- func exampleValueItemsDoesNotValidateMsg(param, path string) errors.Error {
- return errors.New(errors.CompositeErrorCode, ExampleValueItemsDoesNotValidateError, param, path)
- }
- func exampleValueHeaderDoesNotValidateMsg(operation, header, path string) errors.Error {
- return errors.New(errors.CompositeErrorCode, ExampleValueHeaderDoesNotValidateError, operation, header, path)
- }
- func exampleValueHeaderItemsDoesNotValidateMsg(operation, header, path string) errors.Error {
- return errors.New(errors.CompositeErrorCode, ExampleValueHeaderItemsDoesNotValidateError, operation, header, path)
- }
- func exampleValueInDoesNotValidateMsg(operation, path string) errors.Error {
- return errors.New(errors.CompositeErrorCode, ExampleValueInDoesNotValidateError, operation, path)
- }
- func examplesWithoutSchemaMsg(operation, response string) errors.Error {
- return errors.New(errors.CompositeErrorCode, ExamplesWithoutSchemaWarning, operation, response)
- }
- func examplesMimeNotSupportedMsg(operation, response string) errors.Error {
- return errors.New(errors.CompositeErrorCode, ExamplesMimeNotSupportedWarning, operation, response)
- }
- func refNotAllowedInHeaderMsg(path, header, ref string) errors.Error {
- return errors.New(errors.CompositeErrorCode, RefNotAllowedInHeaderError, path, header, ref)
- }
- func cannotResolveRefMsg(path, ref string, err error) errors.Error {
- return errors.New(errors.CompositeErrorCode, CannotResolveReferenceError, path, ref, err)
- }
- func invalidParameterDefinitionMsg(path, method, operationID string) errors.Error {
- return errors.New(errors.CompositeErrorCode, InvalidParameterDefinitionError, path, method, operationID)
- }
- func invalidParameterDefinitionAsSchemaMsg(path, method, operationID string) errors.Error {
- return errors.New(errors.CompositeErrorCode, InvalidParameterDefinitionAsSchemaError, path, method, operationID)
- }
- func someParametersBrokenMsg(path, method, operationID string) errors.Error {
- return errors.New(errors.CompositeErrorCode, SomeParametersBrokenError, path, method, operationID)
- }
- func refShouldNotHaveSiblingsMsg(path, operationID string) errors.Error {
- return errors.New(errors.CompositeErrorCode, RefShouldNotHaveSiblingsWarning, operationID, path)
- }
|