Skip to content

Commit

Permalink
Add CI to verify APIView token schema (#8930)
Browse files Browse the repository at this point in the history
* Add CI to verify APIView token schema
  • Loading branch information
praveenkuttappan authored Sep 7, 2024
1 parent 39dacb7 commit 65dbdb2
Show file tree
Hide file tree
Showing 6 changed files with 218 additions and 133 deletions.
280 changes: 147 additions & 133 deletions tools/apiview/parsers/apiview-treestyle-parser-schema/CodeFile.json
Original file line number Diff line number Diff line change
@@ -1,111 +1,117 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "CodeFile.json",
"type": "object",
"properties": {
"PackageName": {
"type": "string"
},
"PackageVersion": {
"type": "string"
},
"ParserVersion": {
"type": "string",
"description": "version of the APIview language parser used to create token file"
},
"Language": {
"anyOf": [
{
"type": "string",
"const": "C"
},
{
"type": "string",
"const": "C++"
},
{
"type": "string",
"const": "C#"
},
{
"type": "string",
"const": "Go"
},
{
"type": "string",
"const": "Java"
},
{
"type": "string",
"const": "JavaScript"
"$defs": {
"CodeFile": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "CodeFile.json",
"type": "object",
"properties": {
"PackageName": {
"type": "string"
},
{
"type": "string",
"const": "Kotlin"
"PackageVersion": {
"type": "string"
},
{
"ParserVersion": {
"type": "string",
"const": "Python"
"description": "version of the APIview language parser used to create token file"
},
{
"type": "string",
"const": "Swagger"
"Language": {
"anyOf": [
{
"type": "string",
"const": "C"
},
{
"type": "string",
"const": "C++"
},
{
"type": "string",
"const": "C#"
},
{
"type": "string",
"const": "Go"
},
{
"type": "string",
"const": "Java"
},
{
"type": "string",
"const": "JavaScript"
},
{
"type": "string",
"const": "Kotlin"
},
{
"type": "string",
"const": "Python"
},
{
"type": "string",
"const": "Swagger"
},
{
"type": "string",
"const": "Swift"
},
{
"type": "string",
"const": "TypeSpec"
}
]
},
{
"type": "string",
"const": "Swift"
"LanguageVariant": {
"anyOf": [
{
"type": "string",
"const": "None"
},
{
"type": "string",
"const": "Spring"
},
{
"type": "string",
"const": "Android"
}
],
"default": "None",
"description": "Language variant is applicable only for java variants"
},
{
"type": "string",
"const": "TypeSpec"
}
]
},
"LanguageVariant": {
"anyOf": [
{
"type": "string",
"const": "None"
"CrossLanguagePackageId": {
"type": "string"
},
{
"type": "string",
"const": "Spring"
"ReviewLines": {
"type": "array",
"items": {
"$ref": "ReviewLine.json"
}
},
{
"type": "string",
"const": "Android"
"Diagnostics": {
"type": "array",
"items": {
"$ref": "CodeDiagnostic.json"
},
"description": "Add any system generated comments. Each comment is linked to review line ID"
}
},
"required": [
"PackageName",
"PackageVersion",
"ParserVersion",
"Language",
"ReviewLines"
],
"default": "None",
"description": "Language variant is applicable only for java variants"
},
"CrossLanguagePackageId": {
"type": "string"
"description": "ReviewFile represents entire API review object. This will be processed to render review lines."
},
"ReviewLines": {
"type": "array",
"items": {
"$ref": "#/$defs/ReviewLine"
}
},
"Diagnostics": {
"type": "array",
"items": {
"$ref": "#/$defs/CodeDiagnostic"
},
"description": "Add any system generated comments. Each comment is linked to review line ID"
}
},
"required": [
"PackageName",
"PackageVersion",
"ParserVersion",
"Language",
"ReviewLines"
],
"description": "ReviewFile represents entire API review object. This will be processed to render review lines.",
"$defs": {
"ReviewLine": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "ReviewLine.json",
"type": "object",
"properties": {
"LineId": {
Expand All @@ -118,14 +124,14 @@
"Tokens": {
"type": "array",
"items": {
"$ref": "#/$defs/ReviewToken"
"$ref": "ReviewToken.json"
},
"description": "list of tokens that constructs a line in API review"
},
"Children": {
"type": "array",
"items": {
"$ref": "#/$defs/ReviewLine"
"$ref": "ReviewLine.json"
},
"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."
},
Expand All @@ -147,40 +153,13 @@
],
"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."
},
"CodeDiagnostic": {
"type": "object",
"properties": {
"DiagnosticId": {
"type": "string",
"description": "Diagnostic ID is auto generated ID by CSharp analyzer."
},
"TargetId": {
"type": "string",
"description": "Id of ReviewLine object where this diagnostic needs to be displayed"
},
"Text": {
"type": "string",
"description": "Auto generated system comment to be displayed under targeted line."
},
"Level": {
"$ref": "#/$defs/CodeDiagnosticLevel"
},
"HelpLinkUri": {
"type": "string"
}
},
"required": [
"TargetId",
"Text",
"Level"
],
"description": "System comment object is to add system generated comment. It can be one of the 4 different types of system comments."
},
"ReviewToken": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "ReviewToken.json",
"type": "object",
"properties": {
"Kind": {
"$ref": "#/$defs/TokenKind"
"$ref": "TokenKind.json"
},
"Value": {
"type": "string"
Expand Down Expand Up @@ -227,26 +206,61 @@
],
"description": "Token corresponds to each component within a code line. A separate token is required for keyword, punctuation, type name, text etc."
},
"CodeDiagnosticLevel": {
"TokenKind": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "TokenKind.json",
"type": "number",
"enum": [
0,
1,
2,
3,
4
4,
5,
6,
7
]
},
"TokenKind": {
"CodeDiagnostic": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "CodeDiagnostic.json",
"type": "object",
"properties": {
"DiagnosticId": {
"type": "string",
"description": "Diagnostic ID is auto generated ID by CSharp analyzer."
},
"TargetId": {
"type": "string",
"description": "Id of ReviewLine object where this diagnostic needs to be displayed"
},
"Text": {
"type": "string",
"description": "Auto generated system comment to be displayed under targeted line."
},
"Level": {
"$ref": "CodeDiagnosticLevel.json"
},
"HelpLinkUri": {
"type": "string"
}
},
"required": [
"TargetId",
"Text",
"Level"
],
"description": "System comment object is to add system generated comment. It can be one of the 4 different types of system comments."
},
"CodeDiagnosticLevel": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "CodeDiagnosticLevel.json",
"type": "number",
"enum": [
0,
1,
2,
3,
4,
5,
6,
7
4
]
}
}
Expand Down
Loading

0 comments on commit 65dbdb2

Please sign in to comment.