Skip to content

Commit 1b30db9

Browse files
committed
Schema changes to support fileMappings
I updated the schema to draft-07 (the newest VS supports) in order to use the if-else logic. This allows VS to detect that fileMappings are used and then apply a validation error that `"version"` must be set to 3.0. (Trying to do it with an anyOf like for destination/defaultDestination would give a fairly ambiguous message instead.)
1 parent 639bf3e commit 1b30db9

File tree

1 file changed

+63
-10
lines changed

1 file changed

+63
-10
lines changed

src/schema/libman.json

Lines changed: 63 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "http://json-schema.org/draft-04/schema#",
2+
"$schema": "http://json-schema.org/draft-07/schema#",
33
"allOf": [
44
{
55
"anyOf": [
@@ -20,11 +20,19 @@
2020
"$ref": "#/definitions/defaultDestination"
2121
}
2222
]
23+
},
24+
{
25+
"if": {
26+
"$ref": "#/definitions/fileMapping"
27+
},
28+
"then": {
29+
"$ref": "#/definitions/manifestVersion3"
30+
}
2331
}
2432
],
2533
"definitions": {
2634
"libraryEntry": {
27-
"required": ["library"],
35+
"required": [ "library" ],
2836
"properties": {
2937
"files": {
3038
"description": "The file names of the individual files to copy to the project.",
@@ -49,19 +57,47 @@
4957
"description": "The unique identifier of the provider",
5058
"type": "string",
5159
"minLength": 1
60+
},
61+
"fileMappings": {
62+
"description": "A list of file mappings.",
63+
"type": "array",
64+
"items": {
65+
"type": "object",
66+
"properties": {
67+
"root": {
68+
"description": "The mapping root within the library contents. If omitted, defaults to the library root.",
69+
"type": "string",
70+
"minLength": 1
71+
},
72+
"destination": {
73+
"description": "The destination for files included in this mapping. If omitted, defaults to a destination set for the library.",
74+
"type": "string",
75+
"minLength": 1
76+
},
77+
"files": {
78+
"description": "The file names of the individual files to copy to the project, relative to the specified root. If omitted, defaults to all files.",
79+
"type": "array",
80+
"default": null,
81+
"items": {
82+
"type": "string",
83+
"minLength": 1
84+
}
85+
}
86+
}
87+
}
5288
}
5389
}
5490
},
5591
"specifiedProvider": {
5692
"properties": {
5793
"libraries": {
5894
"items": {
59-
"required": ["provider"]
95+
"required": [ "provider" ]
6096
}
6197
}
6298
},
6399
"not": {
64-
"required": ["defaultProvider"]
100+
"required": [ "defaultProvider" ]
65101
}
66102
},
67103
"defaultProvider": {
@@ -77,12 +113,12 @@
77113
"properties": {
78114
"libraries": {
79115
"items": {
80-
"required": ["destination"]
116+
"required": [ "destination" ]
81117
}
82118
}
83119
},
84120
"not": {
85-
"required": ["defaultDestination"]
121+
"required": [ "defaultDestination" ]
86122
}
87123
},
88124
"defaultDestination": {
@@ -93,6 +129,23 @@
93129
"minLength": 1
94130
}
95131
}
132+
},
133+
"fileMapping": {
134+
"properties": {
135+
"libraries": {
136+
"contains": {
137+
"required": [ "fileMappings" ]
138+
}
139+
}
140+
}
141+
},
142+
"manifestVersion3": {
143+
"properties": {
144+
"version": {
145+
"const": "3.0"
146+
}
147+
},
148+
"required": [ "version" ]
96149
}
97150
},
98151
"id": "https://json.schemastore.org/libman.json",
@@ -105,12 +158,12 @@
105158
}
106159
},
107160
"version": {
108-
"description": "The syntax version of this config file. Can only be 1.0",
109-
"enum": ["1.0"],
110-
"default": "1.0"
161+
"description": "The syntax version of this config file.",
162+
"enum": [ "1.0", "3.0" ],
163+
"default": "3.0"
111164
}
112165
},
113-
"required": ["libraries"],
166+
"required": [ "libraries", "version" ],
114167
"title": "JSON schema for client-side library config files",
115168
"type": "object"
116169
}

0 commit comments

Comments
 (0)