Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistent error scheme #449

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions openapiart/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ type validation struct {
validationErrors []string
warnings []string
constraints map[string]map[string]Constraints
parentContext []string
}

type Validation interface {
Expand All @@ -268,6 +269,9 @@ type Validation interface {
under_review(message string)
Warnings() []string
addWarnings(message string)
getParentContext() string
addToParentContext(parentName string)
removeCurrentContext()
}

func (obj *validation) validationResult() error {
Expand Down Expand Up @@ -427,6 +431,18 @@ func (obj *validation) validateHexSlice(hex []string) error {
return obj.validateSlice(hex, "hex")
}

func (obj *validation) getParentContext() string {
return strings.Join(obj.parentContext, ".")
}

func (obj *validation) addToParentContext(parentName string) {
obj.parentContext = append(obj.parentContext, parentName)
}

func (obj *validation) removeCurrentContext() {
obj.parentContext = obj.parentContext[:len(obj.parentContext)-1]
}

// TODO: restore behavior
// func (obj *validation) createMap(objName string) {
// if obj.constraints == nil {
Expand Down
Loading
Loading