Skip to content

Commit

Permalink
Replacing github.com/xeipuuv/gojsonschema with github.com/santhosh-te…
Browse files Browse the repository at this point in the history
…kuri because it seems that the former hasn't been maintained. Also fixing a bug in fallbackregistry (added a test) in which the last loader would've been picked up instead of the former. #15
  • Loading branch information
danielfireman committed Mar 22, 2018
1 parent f05547a commit 5f02d45
Show file tree
Hide file tree
Showing 503 changed files with 10,509 additions and 7,667 deletions.
26 changes: 7 additions & 19 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions datapackage/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/matryer/is"
)

func ExampleNewResourceWithDefaultRegistry() {
func TestNewResourceWithDefaultRegistry(t *testing.T) {
res, _ := NewResourceWithDefaultRegistry(r1)
fmt.Println(res.Name())
// Output: res1
Expand Down Expand Up @@ -324,7 +324,7 @@ func TestResource_ReadAll(t *testing.T) {
}))
defer res2Server.Close()
r, err := NewResource(
map[string]interface{}{"name": "foo", "format": "csv", "path": []string{res1Server.URL, res2Server.URL}, "schema": schemaServer.URL},
map[string]interface{}{"name": "foo", "format": "csv", "path": []interface{}{res1Server.URL, res2Server.URL}, "schema": schemaServer.URL},
validator.MustInMemoryRegistry(),
)
is.NoErr(err)
Expand Down
25 changes: 4 additions & 21 deletions validator/jsonschema.go
Original file line number Diff line number Diff line change
@@ -1,33 +1,16 @@
package validator

import (
"fmt"

"github.com/xeipuuv/gojsonschema"
"github.com/santhosh-tekuri/jsonschema"
)

// jsonSchemaValidator is a validator backed by JSONSchema parsing and validation.
type jsonSchema struct {
schema *gojsonschema.Schema
errors []error
schema *jsonschema.Schema
}

// IsValid checks the passed-in descriptor against the JSONSchema. If it returns
// false, erros can be checked calling Errors() method.
func (v *jsonSchema) IsValid(descriptor map[string]interface{}) bool {
v.errors = nil
result, err := v.schema.Validate(gojsonschema.NewGoLoader(descriptor))
if err != nil {
v.errors = append(v.errors, err)
return false
}
for _, desc := range result.Errors() {
v.errors = append(v.errors, fmt.Errorf(desc.String()))
}
return len(v.errors) == 0
}

// Errors returns the errors found at the last call of IsValid, if any.
func (v *jsonSchema) Errors() []error {
return v.errors
func (v *jsonSchema) Validate(descriptor map[string]interface{}) error {
return v.schema.ValidateInterface(descriptor)
}
2 changes: 0 additions & 2 deletions validator/profile_cache/data-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
},
"description": {
"propertyOrder": 50,
"format": "textarea",
"title": "Description",
"description": "A text description. Markdown is encouraged.",
"type": "string",
Expand Down Expand Up @@ -322,7 +321,6 @@
},
"description": {
"propertyOrder": 60,
"format": "textarea",
"title": "Description",
"description": "A text description. Markdown is encouraged.",
"type": "string",
Expand Down
1 change: 0 additions & 1 deletion validator/profile_cache/data-resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@
},
"description": {
"propertyOrder": 60,
"format": "textarea",
"title": "Description",
"description": "A text description. Markdown is encouraged.",
"type": "string",
Expand Down
3 changes: 0 additions & 3 deletions validator/profile_cache/fiscal-data-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
},
"description": {
"propertyOrder": 50,
"format": "textarea",
"title": "Description",
"description": "A text description. Markdown is encouraged.",
"type": "string",
Expand Down Expand Up @@ -1890,7 +1889,6 @@
},
"description": {
"propertyOrder": 60,
"format": "textarea",
"title": "Description",
"description": "A text description. Markdown is encouraged.",
"type": "string",
Expand Down Expand Up @@ -3896,7 +3894,6 @@
},
"description": {
"propertyOrder": 60,
"format": "textarea",
"title": "Description",
"description": "A text description. Markdown is encouraged.",
"type": "string",
Expand Down
Loading

0 comments on commit 5f02d45

Please sign in to comment.