1
1
package contexts
2
2
3
- import "github.com/aml-org/amf-custom-validator/internal/types"
3
+ import (
4
+ "fmt"
5
+ "github.com/aml-org/amf-custom-validator/internal/types"
6
+ "github.com/aml-org/amf-custom-validator/internal/validator/config"
7
+ )
4
8
5
9
var ApiExtensionUri = "http://a.ml/vocabularies/api-extension#"
6
10
var DefaultAMFContext = types.ObjectMap {
@@ -24,100 +28,111 @@ var DefaultAMFContext = types.ObjectMap{
24
28
"catalog" : "http://anypoint.com/vocabs/digital-repository#" ,
25
29
}
26
30
27
- var DefaultValidationContext = types.ObjectMap {
28
- "actual" : types.StringMap {
29
- "@id" : "http://a.ml/vocabularies/validation#actual" ,
30
- },
31
- "condition" : types.StringMap {
32
- "@id" : "http://a.ml/vocabularies/validation#condition" ,
33
- },
34
- "expected" : types.StringMap {
35
- "@id" : "http://a.ml/vocabularies/validation#expected" ,
36
- },
37
- "negated" : types.StringMap {
38
- "@id" : "http://a.ml/vocabularies/validation#negated" ,
39
- },
40
- "argument" : types.StringMap {
41
- "@id" : "http://a.ml/vocabularies/validation#argument" ,
42
- },
43
- "focusNode" : types.StringMap {
44
- "@id" : "http://www.w3.org/ns/shacl#focusNode" ,
45
- },
46
- "trace" : types.StringMap {
47
- "@id" : "http://a.ml/vocabularies/validation#trace" ,
48
- },
49
- "component" : types.StringMap {
50
- "@id" : "http://a.ml/vocabularies/validation#component" ,
51
- },
52
- "resultPath" : types.StringMap {
53
- "@id" : "http://www.w3.org/ns/shacl#resultPath" ,
54
- },
55
- "traceValue" : types.StringMap {
56
- "@id" : "http://www.w3.org/ns/shacl#traceValue" ,
57
- },
58
- "location" : types.StringMap {
59
- "@id" : "http://a.ml/vocabularies/validation#location" ,
60
- },
61
- "uri" : types.StringMap {
62
- "@id" : "http://a.ml/vocabularies/lexical#uri" ,
63
- },
64
- "start" : types.StringMap {
65
- "@id" : "http://a.ml/vocabularies/lexical#start" ,
66
- },
67
- "end" : types.StringMap {
68
- "@id" : "http://a.ml/vocabularies/lexical#end" ,
69
- },
70
- "range" : types.StringMap {
71
- "@id" : "http://a.ml/vocabularies/lexical#range" ,
72
- },
73
- "line" : types.StringMap {
74
- "@id" : "http://a.ml/vocabularies/lexical#line" ,
75
- },
76
- "column" : types.StringMap {
77
- "@id" : "http://a.ml/vocabularies/lexical#column" ,
78
- },
79
- "sourceShapeName" : types.StringMap {
80
- "@id" : "http://a.ml/vocabularies/validation#sourceShapeName" ,
81
- },
82
- "conforms" : types.StringMap {
83
- "@id" : "http://www.w3.org/ns/shacl#conforms" ,
84
- },
85
- "dateCreated" : types.StringMap {
86
- "@id" : "http://a.ml/vocabularies/core##dateCreated" ,
87
- },
88
- "profileName" : types.StringMap {
89
- "@id" : "http://a.ml/vocabularies/validation#profileName" ,
90
- },
91
- "result" : types.StringMap {
92
- "@id" : "http://www.w3.org/ns/shacl#result" ,
93
- },
94
- "subResult" : types.StringMap {
95
- "@id" : "http://a.ml/vocabularies/validation#subResult" ,
96
- },
97
- "resultSeverity" : types.StringMap {
98
- "@id" : "http://www.w3.org/ns/shacl#resultSeverity" ,
99
- },
100
- "resultMessage" : types.StringMap {
101
- "@id" : "http://www.w3.org/ns/shacl#resultMessage" ,
102
- },
103
- "shacl" : "http://www.w3.org/ns/shacl#" ,
104
- "doc" : "http://a.ml/vocabularies/document#" ,
105
- "meta" : "http://a.ml/vocabularies/meta#" ,
106
- "validation" : "http://a.ml/vocabularies/validation#" ,
107
- "lexical" : "http://a.ml/vocabularies/lexical#" ,
108
- "reportSchema" : reportPath ,
109
- "lexicalSchema" : lexicalPath ,
31
+ func DefaultValidationContext (reportConfig config.ReportConfiguration ) types.ObjectMap {
32
+ return types.ObjectMap {
33
+ "actual" : types.StringMap {
34
+ "@id" : "http://a.ml/vocabularies/validation#actual" ,
35
+ },
36
+ "condition" : types.StringMap {
37
+ "@id" : "http://a.ml/vocabularies/validation#condition" ,
38
+ },
39
+ "expected" : types.StringMap {
40
+ "@id" : "http://a.ml/vocabularies/validation#expected" ,
41
+ },
42
+ "negated" : types.StringMap {
43
+ "@id" : "http://a.ml/vocabularies/validation#negated" ,
44
+ },
45
+ "argument" : types.StringMap {
46
+ "@id" : "http://a.ml/vocabularies/validation#argument" ,
47
+ },
48
+ "focusNode" : types.StringMap {
49
+ "@id" : "http://www.w3.org/ns/shacl#focusNode" ,
50
+ },
51
+ "trace" : types.StringMap {
52
+ "@id" : "http://a.ml/vocabularies/validation#trace" ,
53
+ },
54
+ "component" : types.StringMap {
55
+ "@id" : "http://a.ml/vocabularies/validation#component" ,
56
+ },
57
+ "resultPath" : types.StringMap {
58
+ "@id" : "http://www.w3.org/ns/shacl#resultPath" ,
59
+ },
60
+ "traceValue" : types.StringMap {
61
+ "@id" : "http://www.w3.org/ns/shacl#traceValue" ,
62
+ },
63
+ "location" : types.StringMap {
64
+ "@id" : "http://a.ml/vocabularies/validation#location" ,
65
+ },
66
+ "uri" : types.StringMap {
67
+ "@id" : "http://a.ml/vocabularies/lexical#uri" ,
68
+ },
69
+ "start" : types.StringMap {
70
+ "@id" : "http://a.ml/vocabularies/lexical#start" ,
71
+ },
72
+ "end" : types.StringMap {
73
+ "@id" : "http://a.ml/vocabularies/lexical#end" ,
74
+ },
75
+ "range" : types.StringMap {
76
+ "@id" : "http://a.ml/vocabularies/lexical#range" ,
77
+ },
78
+ "line" : types.StringMap {
79
+ "@id" : "http://a.ml/vocabularies/lexical#line" ,
80
+ },
81
+ "column" : types.StringMap {
82
+ "@id" : "http://a.ml/vocabularies/lexical#column" ,
83
+ },
84
+ "sourceShapeName" : types.StringMap {
85
+ "@id" : "http://a.ml/vocabularies/validation#sourceShapeName" ,
86
+ },
87
+ "conforms" : types.StringMap {
88
+ "@id" : "http://www.w3.org/ns/shacl#conforms" ,
89
+ },
90
+ "dateCreated" : types.StringMap {
91
+ "@id" : "http://a.ml/vocabularies/core#dateCreated" ,
92
+ },
93
+ "profileName" : types.StringMap {
94
+ "@id" : "http://a.ml/vocabularies/validation#profileName" ,
95
+ },
96
+ "result" : types.StringMap {
97
+ "@id" : "http://www.w3.org/ns/shacl#result" ,
98
+ },
99
+ "subResult" : types.StringMap {
100
+ "@id" : "http://a.ml/vocabularies/validation#subResult" ,
101
+ },
102
+ "resultSeverity" : types.StringMap {
103
+ "@id" : "http://www.w3.org/ns/shacl#resultSeverity" ,
104
+ },
105
+ "resultMessage" : types.StringMap {
106
+ "@id" : "http://www.w3.org/ns/shacl#resultMessage" ,
107
+ },
108
+ "shacl" : "http://www.w3.org/ns/shacl#" ,
109
+ "doc" : "http://a.ml/vocabularies/document#" ,
110
+ "meta" : "http://a.ml/vocabularies/meta#" ,
111
+ "validation" : "http://a.ml/vocabularies/validation#" ,
112
+ "lexical" : "http://a.ml/vocabularies/lexical#" ,
113
+ "reportSchema" : DeclarationsFrom (reportConfig .ReportSchemaIri ),
114
+ "lexicalSchema" : DeclarationsFrom (reportConfig .LexicalSchemaIri ),
115
+ }
110
116
}
111
117
112
- var reportPath = "file:///dialects/validation-report.yaml#/declarations/"
113
- var lexicalPath = "file:///dialects/lexical.yaml#/declarations/"
118
+ func ConformsContext (reportConfig config.ReportConfiguration ) types.ObjectMap {
119
+ return types.ObjectMap {
120
+ "conforms" : types.StringMap {
121
+ "@id" : "http://www.w3.org/ns/shacl#conforms" ,
122
+ },
123
+ "shacl" : "http://www.w3.org/ns/shacl#" ,
124
+ "doc" : "http://a.ml/vocabularies/document#" ,
125
+ "reportSchema" : DeclarationsFrom (reportConfig .ReportSchemaIri ),
126
+ "meta" : "http://a.ml/vocabularies/meta#" ,
127
+ "dateCreated" : types.StringMap {
128
+ "@id" : "http://a.ml/vocabularies/core#dateCreated" ,
129
+ },
130
+ "profileName" : types.StringMap {
131
+ "@id" : "http://a.ml/vocabularies/validation#profileName" ,
132
+ },
133
+ }
134
+ }
114
135
115
- var ConformsContext = types.ObjectMap {
116
- "conforms" : types.StringMap {
117
- "@id" : "http://www.w3.org/ns/shacl#conforms" ,
118
- },
119
- "shacl" : "http://www.w3.org/ns/shacl#" ,
120
- "doc" : "http://a.ml/vocabularies/document#" ,
121
- "reportSchema" : reportPath ,
122
- "meta" : "http://a.ml/vocabularies/meta#" ,
136
+ func DeclarationsFrom (schemaIri string ) string {
137
+ return fmt .Sprintf ("%s#/declarations/" , schemaIri )
123
138
}
0 commit comments