Skip to content

Commit 65dbdb2

Browse files
Add CI to verify APIView token schema (#8930)
* Add CI to verify APIView token schema
1 parent 39dacb7 commit 65dbdb2

File tree

6 files changed

+218
-133
lines changed

6 files changed

+218
-133
lines changed

tools/apiview/parsers/apiview-treestyle-parser-schema/CodeFile.json

+147-133
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,117 @@
11
{
22
"$schema": "https://json-schema.org/draft/2020-12/schema",
33
"$id": "CodeFile.json",
4-
"type": "object",
5-
"properties": {
6-
"PackageName": {
7-
"type": "string"
8-
},
9-
"PackageVersion": {
10-
"type": "string"
11-
},
12-
"ParserVersion": {
13-
"type": "string",
14-
"description": "version of the APIview language parser used to create token file"
15-
},
16-
"Language": {
17-
"anyOf": [
18-
{
19-
"type": "string",
20-
"const": "C"
21-
},
22-
{
23-
"type": "string",
24-
"const": "C++"
25-
},
26-
{
27-
"type": "string",
28-
"const": "C#"
29-
},
30-
{
31-
"type": "string",
32-
"const": "Go"
33-
},
34-
{
35-
"type": "string",
36-
"const": "Java"
37-
},
38-
{
39-
"type": "string",
40-
"const": "JavaScript"
4+
"$defs": {
5+
"CodeFile": {
6+
"$schema": "https://json-schema.org/draft/2020-12/schema",
7+
"$id": "CodeFile.json",
8+
"type": "object",
9+
"properties": {
10+
"PackageName": {
11+
"type": "string"
4112
},
42-
{
43-
"type": "string",
44-
"const": "Kotlin"
13+
"PackageVersion": {
14+
"type": "string"
4515
},
46-
{
16+
"ParserVersion": {
4717
"type": "string",
48-
"const": "Python"
18+
"description": "version of the APIview language parser used to create token file"
4919
},
50-
{
51-
"type": "string",
52-
"const": "Swagger"
20+
"Language": {
21+
"anyOf": [
22+
{
23+
"type": "string",
24+
"const": "C"
25+
},
26+
{
27+
"type": "string",
28+
"const": "C++"
29+
},
30+
{
31+
"type": "string",
32+
"const": "C#"
33+
},
34+
{
35+
"type": "string",
36+
"const": "Go"
37+
},
38+
{
39+
"type": "string",
40+
"const": "Java"
41+
},
42+
{
43+
"type": "string",
44+
"const": "JavaScript"
45+
},
46+
{
47+
"type": "string",
48+
"const": "Kotlin"
49+
},
50+
{
51+
"type": "string",
52+
"const": "Python"
53+
},
54+
{
55+
"type": "string",
56+
"const": "Swagger"
57+
},
58+
{
59+
"type": "string",
60+
"const": "Swift"
61+
},
62+
{
63+
"type": "string",
64+
"const": "TypeSpec"
65+
}
66+
]
5367
},
54-
{
55-
"type": "string",
56-
"const": "Swift"
68+
"LanguageVariant": {
69+
"anyOf": [
70+
{
71+
"type": "string",
72+
"const": "None"
73+
},
74+
{
75+
"type": "string",
76+
"const": "Spring"
77+
},
78+
{
79+
"type": "string",
80+
"const": "Android"
81+
}
82+
],
83+
"default": "None",
84+
"description": "Language variant is applicable only for java variants"
5785
},
58-
{
59-
"type": "string",
60-
"const": "TypeSpec"
61-
}
62-
]
63-
},
64-
"LanguageVariant": {
65-
"anyOf": [
66-
{
67-
"type": "string",
68-
"const": "None"
86+
"CrossLanguagePackageId": {
87+
"type": "string"
6988
},
70-
{
71-
"type": "string",
72-
"const": "Spring"
89+
"ReviewLines": {
90+
"type": "array",
91+
"items": {
92+
"$ref": "ReviewLine.json"
93+
}
7394
},
74-
{
75-
"type": "string",
76-
"const": "Android"
95+
"Diagnostics": {
96+
"type": "array",
97+
"items": {
98+
"$ref": "CodeDiagnostic.json"
99+
},
100+
"description": "Add any system generated comments. Each comment is linked to review line ID"
77101
}
102+
},
103+
"required": [
104+
"PackageName",
105+
"PackageVersion",
106+
"ParserVersion",
107+
"Language",
108+
"ReviewLines"
78109
],
79-
"default": "None",
80-
"description": "Language variant is applicable only for java variants"
81-
},
82-
"CrossLanguagePackageId": {
83-
"type": "string"
110+
"description": "ReviewFile represents entire API review object. This will be processed to render review lines."
84111
},
85-
"ReviewLines": {
86-
"type": "array",
87-
"items": {
88-
"$ref": "#/$defs/ReviewLine"
89-
}
90-
},
91-
"Diagnostics": {
92-
"type": "array",
93-
"items": {
94-
"$ref": "#/$defs/CodeDiagnostic"
95-
},
96-
"description": "Add any system generated comments. Each comment is linked to review line ID"
97-
}
98-
},
99-
"required": [
100-
"PackageName",
101-
"PackageVersion",
102-
"ParserVersion",
103-
"Language",
104-
"ReviewLines"
105-
],
106-
"description": "ReviewFile represents entire API review object. This will be processed to render review lines.",
107-
"$defs": {
108112
"ReviewLine": {
113+
"$schema": "https://json-schema.org/draft/2020-12/schema",
114+
"$id": "ReviewLine.json",
109115
"type": "object",
110116
"properties": {
111117
"LineId": {
@@ -118,14 +124,14 @@
118124
"Tokens": {
119125
"type": "array",
120126
"items": {
121-
"$ref": "#/$defs/ReviewToken"
127+
"$ref": "ReviewToken.json"
122128
},
123129
"description": "list of tokens that constructs a line in API review"
124130
},
125131
"Children": {
126132
"type": "array",
127133
"items": {
128-
"$ref": "#/$defs/ReviewLine"
134+
"$ref": "ReviewLine.json"
129135
},
130136
"description": "Add any child lines as children. For e.g. all classes and namespace level methods are added as a children of namespace(module) level code line. \nSimilarly all method level code lines are added as children of it's class code line."
131137
},
@@ -147,40 +153,13 @@
147153
],
148154
"description": "ReviewLine object corresponds to each line displayed on API review. If an empty line is required then add a code line object without any token."
149155
},
150-
"CodeDiagnostic": {
151-
"type": "object",
152-
"properties": {
153-
"DiagnosticId": {
154-
"type": "string",
155-
"description": "Diagnostic ID is auto generated ID by CSharp analyzer."
156-
},
157-
"TargetId": {
158-
"type": "string",
159-
"description": "Id of ReviewLine object where this diagnostic needs to be displayed"
160-
},
161-
"Text": {
162-
"type": "string",
163-
"description": "Auto generated system comment to be displayed under targeted line."
164-
},
165-
"Level": {
166-
"$ref": "#/$defs/CodeDiagnosticLevel"
167-
},
168-
"HelpLinkUri": {
169-
"type": "string"
170-
}
171-
},
172-
"required": [
173-
"TargetId",
174-
"Text",
175-
"Level"
176-
],
177-
"description": "System comment object is to add system generated comment. It can be one of the 4 different types of system comments."
178-
},
179156
"ReviewToken": {
157+
"$schema": "https://json-schema.org/draft/2020-12/schema",
158+
"$id": "ReviewToken.json",
180159
"type": "object",
181160
"properties": {
182161
"Kind": {
183-
"$ref": "#/$defs/TokenKind"
162+
"$ref": "TokenKind.json"
184163
},
185164
"Value": {
186165
"type": "string"
@@ -227,26 +206,61 @@
227206
],
228207
"description": "Token corresponds to each component within a code line. A separate token is required for keyword, punctuation, type name, text etc."
229208
},
230-
"CodeDiagnosticLevel": {
209+
"TokenKind": {
210+
"$schema": "https://json-schema.org/draft/2020-12/schema",
211+
"$id": "TokenKind.json",
231212
"type": "number",
232213
"enum": [
214+
0,
233215
1,
234216
2,
235217
3,
236-
4
218+
4,
219+
5,
220+
6,
221+
7
237222
]
238223
},
239-
"TokenKind": {
224+
"CodeDiagnostic": {
225+
"$schema": "https://json-schema.org/draft/2020-12/schema",
226+
"$id": "CodeDiagnostic.json",
227+
"type": "object",
228+
"properties": {
229+
"DiagnosticId": {
230+
"type": "string",
231+
"description": "Diagnostic ID is auto generated ID by CSharp analyzer."
232+
},
233+
"TargetId": {
234+
"type": "string",
235+
"description": "Id of ReviewLine object where this diagnostic needs to be displayed"
236+
},
237+
"Text": {
238+
"type": "string",
239+
"description": "Auto generated system comment to be displayed under targeted line."
240+
},
241+
"Level": {
242+
"$ref": "CodeDiagnosticLevel.json"
243+
},
244+
"HelpLinkUri": {
245+
"type": "string"
246+
}
247+
},
248+
"required": [
249+
"TargetId",
250+
"Text",
251+
"Level"
252+
],
253+
"description": "System comment object is to add system generated comment. It can be one of the 4 different types of system comments."
254+
},
255+
"CodeDiagnosticLevel": {
256+
"$schema": "https://json-schema.org/draft/2020-12/schema",
257+
"$id": "CodeDiagnosticLevel.json",
240258
"type": "number",
241259
"enum": [
242-
0,
243260
1,
244261
2,
245262
3,
246-
4,
247-
5,
248-
6,
249-
7
263+
4
250264
]
251265
}
252266
}

0 commit comments

Comments
 (0)