Skip to content

Add schemas path parameter to libraryproperties.Validate() #22

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

Merged
Merged
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
3 changes: 2 additions & 1 deletion check/checkdata/library.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package checkdata

import (
"github.com/arduino/arduino-check/configuration"
"github.com/arduino/arduino-check/project"
"github.com/arduino/arduino-check/project/library/libraryproperties"
"github.com/arduino/go-properties-orderedmap"
Expand All @@ -29,7 +30,7 @@ func InitializeForLibrary(project project.Type) {
// TODO: can I even do this?
libraryPropertiesSchemaValidationResult = nil
} else {
libraryPropertiesSchemaValidationResult = libraryproperties.Validate(libraryProperties)
libraryPropertiesSchemaValidationResult = libraryproperties.Validate(libraryProperties, configuration.SchemasPath())
}
}

Expand Down
7 changes: 3 additions & 4 deletions project/library/libraryproperties/libraryproperties.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package libraryproperties

import (
"github.com/arduino/arduino-check/check/checkdata/schema"
"github.com/arduino/arduino-check/configuration"
"github.com/arduino/go-paths-helper"
"github.com/arduino/go-properties-orderedmap"
"github.com/ory/jsonschema/v3"
Expand All @@ -34,9 +33,9 @@ func Properties(libraryPath *paths.Path) (*properties.Map, error) {
}

// Validate validates library.properties data against the JSON schema.
func Validate(libraryProperties *properties.Map) *jsonschema.ValidationError {
func Validate(libraryProperties *properties.Map, schemasPath *paths.Path) *jsonschema.ValidationError {
referencedSchemaFilenames := []string{}
schemaObject := schema.Compile("arduino-library-properties-schema.json", referencedSchemaFilenames, configuration.SchemasPath())
schemaObject := schema.Compile("arduino-library-properties-schema.json", referencedSchemaFilenames, schemasPath)

return schema.Validate(libraryProperties, schemaObject, configuration.SchemasPath())
return schema.Validate(libraryProperties, schemaObject, schemasPath)
}