(err validationError)
| 108 | ) |
| 109 | |
| 110 | func getDescription(err validationError) string { |
| 111 | switch err.parent.Type() { |
| 112 | case "invalid_type": |
| 113 | if expectedType, ok := err.parent.Details()["expected"].(string); ok { |
| 114 | return "must be a " + humanReadableType(expectedType) |
| 115 | } |
| 116 | case jsonschemaOneOf, jsonschemaAnyOf: |
| 117 | if err.child == nil { |
| 118 | return err.parent.Description() |
| 119 | } |
| 120 | return err.child.Description() |
| 121 | } |
| 122 | return err.parent.Description() |
| 123 | } |
| 124 | |
| 125 | func humanReadableType(definition string) string { |
| 126 | if definition[0:1] == "[" { |
no test coverage detected
searching dependent graphs…