Skip to content
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions internal/validator/contexts/contexts.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var DefaultAMFContext = types.ObjectMap{

func DefaultValidationContext(reportConfig config.ReportConfiguration) types.ObjectMap {
return types.ObjectMap{
"@base": reportConfig.BaseIri,
"actual": types.StringMap{
"@id": "http://a.ml/vocabularies/validation#actual",
},
Expand Down Expand Up @@ -117,6 +118,7 @@ func DefaultValidationContext(reportConfig config.ReportConfiguration) types.Obj

func ConformsContext(reportConfig config.ReportConfiguration) types.ObjectMap {
return types.ObjectMap{
"@base": reportConfig.BaseIri,
"conforms": types.StringMap{
"@id": "http://www.w3.org/ns/shacl#conforms",
},
Expand Down
32 changes: 32 additions & 0 deletions internal/validator/validate_configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,35 @@ func TestAlternativeSchemas(t *testing.T) {
t.Errorf("Actual '%s' does not match expected '%s'", actual, expected)
}
}

func TestAlernativeBaseIri(t *testing.T) {
baseIri := "http://a.ml/my-really-cool-custom-iri"

reportConfig := c.ReportConfiguration{
BaseIri: baseIri,
}

profile := read("../../test/data/integration/profile1/profile.yaml")
data := read("../../test/data/integration/profile1/negative.data.jsonld")

report, err := ValidateWithConfiguration(profile, data, config.Debug, nil, c.TestValidationConfiguration{}, reportConfig)

if err != nil {
t.Errorf("Error during validation\n")
}

var output []any
err = json.Unmarshal([]byte(report), &output)
if err != nil {
t.Errorf("Error during report JSON unmarshling\n")
}
doc := output[0].(map[string]any)
context := doc["@context"].(map[string]any)

actual := context["@base"].(string)
expected := baseIri

if actual != expected {
t.Errorf("Actual '%s' does not match expected '%s'", actual, expected)
}
}
2 changes: 2 additions & 0 deletions pkg/config/report_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ type ReportConfiguration struct {
IncludeReportCreationTime bool
ReportSchemaIri string
LexicalSchemaIri string
BaseIri string
}

func DefaultReportConfiguration() ReportConfiguration {
return ReportConfiguration{
IncludeReportCreationTime: true,
ReportSchemaIri: "file:///dialects/validation-report.yaml",
LexicalSchemaIri: "file:///dialects/lexical.yaml",
BaseIri: "http://a.ml/vocabularies/validation/report#",
}
}
1 change: 1 addition & 0 deletions test/data/integration/profile1/negative.report.jsonld
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"@context": {
"@base": "http://a.ml/vocabularies/validation/report#",
"actual": {
"@id": "http://a.ml/vocabularies/validation#actual"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"@context": {
"@base": "http://a.ml/vocabularies/validation/report#",
"actual": {
"@id": "http://a.ml/vocabularies/validation#actual"
},
Expand Down
1 change: 1 addition & 0 deletions test/data/integration/profile1/positive.report.jsonld
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"@context": {
"@base": "http://a.ml/vocabularies/validation/report#",
"conforms": {
"@id": "http://www.w3.org/ns/shacl#conforms"
},
Expand Down
1 change: 1 addition & 0 deletions test/data/integration/profile10/negative.report.jsonld
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"@context": {
"@base": "http://a.ml/vocabularies/validation/report#",
"actual": {
"@id": "http://a.ml/vocabularies/validation#actual"
},
Expand Down
1 change: 1 addition & 0 deletions test/data/integration/profile10/positive.report.jsonld
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"@context": {
"@base": "http://a.ml/vocabularies/validation/report#",
"conforms": {
"@id": "http://www.w3.org/ns/shacl#conforms"
},
Expand Down
1 change: 1 addition & 0 deletions test/data/integration/profile11/negative.report.jsonld
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"@context": {
"@base": "http://a.ml/vocabularies/validation/report#",
"actual": {
"@id": "http://a.ml/vocabularies/validation#actual"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"@context": {
"@base": "http://a.ml/vocabularies/validation/report#",
"actual": {
"@id": "http://a.ml/vocabularies/validation#actual"
},
Expand Down
1 change: 1 addition & 0 deletions test/data/integration/profile11/positive.report.jsonld
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"@context": {
"@base": "http://a.ml/vocabularies/validation/report#",
"conforms": {
"@id": "http://www.w3.org/ns/shacl#conforms"
},
Expand Down
1 change: 1 addition & 0 deletions test/data/integration/profile12/negative.report.jsonld
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"@context": {
"@base": "http://a.ml/vocabularies/validation/report#",
"actual": {
"@id": "http://a.ml/vocabularies/validation#actual"
},
Expand Down
1 change: 1 addition & 0 deletions test/data/integration/profile12/positive.report.jsonld
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"@context": {
"@base": "http://a.ml/vocabularies/validation/report#",
"conforms": {
"@id": "http://www.w3.org/ns/shacl#conforms"
},
Expand Down
1 change: 1 addition & 0 deletions test/data/integration/profile13/negative.report.jsonld
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"@context": {
"@base": "http://a.ml/vocabularies/validation/report#",
"actual": {
"@id": "http://a.ml/vocabularies/validation#actual"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"@context": {
"@base": "http://a.ml/vocabularies/validation/report#",
"actual": {
"@id": "http://a.ml/vocabularies/validation#actual"
},
Expand Down
1 change: 1 addition & 0 deletions test/data/integration/profile13/positive.report.jsonld
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"@context": {
"@base": "http://a.ml/vocabularies/validation/report#",
"conforms": {
"@id": "http://www.w3.org/ns/shacl#conforms"
},
Expand Down
1 change: 1 addition & 0 deletions test/data/integration/profile14/negative.report.jsonld
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"@context": {
"@base": "http://a.ml/vocabularies/validation/report#",
"actual": {
"@id": "http://a.ml/vocabularies/validation#actual"
},
Expand Down
1 change: 1 addition & 0 deletions test/data/integration/profile14/positive.report.jsonld
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"@context": {
"@base": "http://a.ml/vocabularies/validation/report#",
"conforms": {
"@id": "http://www.w3.org/ns/shacl#conforms"
},
Expand Down
2 changes: 1 addition & 1 deletion test/data/integration/profile15/negative.data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ components:
name:
description: a property
type: string
required: ["id"]
required: [ "id" ]

paths:
/users:
Expand Down
1 change: 1 addition & 0 deletions test/data/integration/profile15/negative.report.jsonld
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"@context": {
"@base": "http://a.ml/vocabularies/validation/report#",
"actual": {
"@id": "http://a.ml/vocabularies/validation#actual"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"@context": {
"@base": "http://a.ml/vocabularies/validation/report#",
"actual": {
"@id": "http://a.ml/vocabularies/validation#actual"
},
Expand Down
2 changes: 1 addition & 1 deletion test/data/integration/profile15/positive.data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ components:
name:
description: a property
type: string
required: ["id"]
required: [ "id" ]

paths:
/users:
Expand Down
1 change: 1 addition & 0 deletions test/data/integration/profile15/positive.report.jsonld
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"@context": {
"@base": "http://a.ml/vocabularies/validation/report#",
"conforms": {
"@id": "http://www.w3.org/ns/shacl#conforms"
},
Expand Down
2 changes: 1 addition & 1 deletion test/data/integration/profile16/negative.data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ components:
name:
description: a property
type: string
required: ["id"]
required: [ "id" ]

paths:
/users:
Expand Down
1 change: 1 addition & 0 deletions test/data/integration/profile16/negative.report.jsonld
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"@context": {
"@base": "http://a.ml/vocabularies/validation/report#",
"actual": {
"@id": "http://a.ml/vocabularies/validation#actual"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"@context": {
"@base": "http://a.ml/vocabularies/validation/report#",
"actual": {
"@id": "http://a.ml/vocabularies/validation#actual"
},
Expand Down
2 changes: 1 addition & 1 deletion test/data/integration/profile16/positive.data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ components:
name:
description: a property
type: string
required: ["id"]
required: [ "id" ]

paths:
/users:
Expand Down
1 change: 1 addition & 0 deletions test/data/integration/profile16/positive.report.jsonld
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"@context": {
"@base": "http://a.ml/vocabularies/validation/report#",
"conforms": {
"@id": "http://www.w3.org/ns/shacl#conforms"
},
Expand Down
2 changes: 1 addition & 1 deletion test/data/integration/profile17/negative.data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ openapi: 3.0.0
info:
title: Example API
version: '1.0'
paths: {}
paths: { }
1 change: 1 addition & 0 deletions test/data/integration/profile17/negative.report.jsonld
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"@context": {
"@base": "http://a.ml/vocabularies/validation/report#",
"actual": {
"@id": "http://a.ml/vocabularies/validation#actual"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"@context": {
"@base": "http://a.ml/vocabularies/validation/report#",
"actual": {
"@id": "http://a.ml/vocabularies/validation#actual"
},
Expand Down
2 changes: 1 addition & 1 deletion test/data/integration/profile17/positive.data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ openapi: 3.0.0
info:
title: Example API
version: 'v1.1.0'
paths: {}
paths: { }
1 change: 1 addition & 0 deletions test/data/integration/profile17/positive.report.jsonld
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"@context": {
"@base": "http://a.ml/vocabularies/validation/report#",
"conforms": {
"@id": "http://www.w3.org/ns/shacl#conforms"
},
Expand Down
1 change: 1 addition & 0 deletions test/data/integration/profile18/negative.report.jsonld
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"@context": {
"@base": "http://a.ml/vocabularies/validation/report#",
"actual": {
"@id": "http://a.ml/vocabularies/validation#actual"
},
Expand Down
2 changes: 1 addition & 1 deletion test/data/integration/profile18/positive.data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ openapi: "3.0.0"
info:
title: example API
version: "1.0.0"
paths: {}
paths: { }
x-wadus:
hola: mundo
things:
Expand Down
1 change: 1 addition & 0 deletions test/data/integration/profile18/positive.report.jsonld
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"@context": {
"@base": "http://a.ml/vocabularies/validation/report#",
"conforms": {
"@id": "http://www.w3.org/ns/shacl#conforms"
},
Expand Down
1 change: 1 addition & 0 deletions test/data/integration/profile19/negative.report.jsonld
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"@context": {
"@base": "http://a.ml/vocabularies/validation/report#",
"actual": {
"@id": "http://a.ml/vocabularies/validation#actual"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"@context": {
"@base": "http://a.ml/vocabularies/validation/report#",
"actual": {
"@id": "http://a.ml/vocabularies/validation#actual"
},
Expand Down
1 change: 1 addition & 0 deletions test/data/integration/profile19/positive.report.jsonld
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"@context": {
"@base": "http://a.ml/vocabularies/validation/report#",
"conforms": {
"@id": "http://www.w3.org/ns/shacl#conforms"
},
Expand Down
1 change: 1 addition & 0 deletions test/data/integration/profile2/negative.report.jsonld
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"@context": {
"@base": "http://a.ml/vocabularies/validation/report#",
"actual": {
"@id": "http://a.ml/vocabularies/validation#actual"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"@context": {
"@base": "http://a.ml/vocabularies/validation/report#",
"actual": {
"@id": "http://a.ml/vocabularies/validation#actual"
},
Expand Down
1 change: 1 addition & 0 deletions test/data/integration/profile2/positive.report.jsonld
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"@context": {
"@base": "http://a.ml/vocabularies/validation/report#",
"conforms": {
"@id": "http://www.w3.org/ns/shacl#conforms"
},
Expand Down
1 change: 1 addition & 0 deletions test/data/integration/profile20/negative.report.jsonld
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"@context": {
"@base": "http://a.ml/vocabularies/validation/report#",
"actual": {
"@id": "http://a.ml/vocabularies/validation#actual"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"@context": {
"@base": "http://a.ml/vocabularies/validation/report#",
"actual": {
"@id": "http://a.ml/vocabularies/validation#actual"
},
Expand Down
Loading