-
Notifications
You must be signed in to change notification settings - Fork 221
APIView code file token tsp and json schema #8816
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
praveenkuttappan
merged 17 commits into
Azure:main
from
praveenkuttappan:apiview_token_schema
Aug 19, 2024
Merged
Changes from 2 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
fd3d0c9
APIView code file token tsp and json schema
praveenkuttappan fb583ca
Renamed yaml file
praveenkuttappan 55bb7a6
Added subkind
praveenkuttappan 36edd29
Update the comment about skipdiff
praveenkuttappan 1e6dc61
Updated mdel names to avoid ambiguity with old models
praveenkuttappan bd406f0
Schema changes to remove subkind
praveenkuttappan d6bf73b
Moved schema to parser folder and removed old schema
praveenkuttappan b78b194
Added sample JSON and review context text from the token
praveenkuttappan 98b082d
Remove duplicate ishidden
praveenkuttappan c4c2efc
Schema changes to use existing code diagnostic objects
praveenkuttappan c604a2d
Update contributing guide
praveenkuttappan 1f6e391
Update contributing guide
praveenkuttappan 235a3a9
Update contributing guide
praveenkuttappan b340e7e
Apply suggestions from code review
praveenkuttappan fccfe2a
Apply suggestions from code review
praveenkuttappan 7f55b5b
Added documentation for fatal level diag
praveenkuttappan 4c343c3
Update tools/apiview/parsers/CONTRIBUTING.md
praveenkuttappan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| import "@typespec/json-schema"; | ||
|
|
||
| using TypeSpec.JsonSchema; | ||
|
|
||
| @jsonSchema | ||
|
|
||
| /** CodeFile represents entire API review object. This will be processed to render review lines. */ | ||
| model CodeFile { | ||
| packageName: string; | ||
| packageVersion: string; | ||
| /** version of the APIview language parser used to create token file*/ | ||
| parserVersion: string; | ||
| language: "C"|"C++"|"C#"|"Go"|"Java"|"JavaScript"|"Kotlin"|"Python"|"Swagger"|"Swift"|"TypeSpec"; | ||
| /** Language variant is applicable only for java variants*/ | ||
| languageVariant?: "None" | "Spring" | "Android" = "None"; | ||
| crossLanguagePackageId?: string; | ||
| codeLines: Array<CodeLine>; | ||
| /** Add any system generated comments for the current token. */ | ||
| systemComments?: Array<CodeDiagnostic>; | ||
praveenkuttappan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
|
|
||
| /** Code line object corresponds to each line displayed on API review. If an empty line is required then add a code line object without any token. */ | ||
| model CodeLine { | ||
| /** lineId is only required if we need to support commenting on a line that contains this token. | ||
| * Usually code line for documentation or just punctuation is not required to have lineId. lineId should be a unique value within | ||
| * the review token file to use it assign to review comments as well as navigation Id within the review page. | ||
| * for e.g Azure.Core.HttpHeader.Common, azure.template.template_main | ||
| */ | ||
| lineId?: string; | ||
| crossLanguageId?: string; | ||
| /** list of tokens that constructs a line in API review */ | ||
| tokens: Array<Token>; | ||
| /** 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. | ||
| * Similarly all method level code lines are added as children of it's class code line.*/ | ||
| children?: Array<CodeLine>; | ||
| } | ||
|
|
||
|
|
||
| /** Token corresponds to each component within a code line. A separate token is required for keyword, punctuation, type name, text etc. */ | ||
| model Token { | ||
| kind: TokenKind; | ||
| value: string; | ||
| /** navigateToId should be set if the underlying token is required to be displayed as HREF to another type within the review. | ||
| * For e.g. a param type which is class name in the same package | ||
| */ | ||
| navigateToId?: string; | ||
| /** set skipDiff to true if underlying token needs to be ignored from diff calculation. For e.g. package metadata or dependency versions | ||
| * are usually not required to be excluded when comparing two revisions to avoid reporting them as API changes*/ | ||
praveenkuttappan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| skipDiff?: boolean = false; | ||
| /** This is set if API is marked as hidden */ | ||
| isHidden?: boolean = false; | ||
praveenkuttappan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| /** This is set if API is marked as deprecated */ | ||
| isDeprecated?: boolean = false; | ||
| /** Set this to false if there is no suffix space required before next token. For e.g, punctuation right after method name */ | ||
| hasSuffixSpace?: boolean = true; | ||
| /** Set isDocumentation to true if current token is part of documentation */ | ||
| isDocumentation?: boolean = false; | ||
| /** Language specific style css class names */ | ||
| languageStyleClasses?: Array<string>; | ||
praveenkuttappan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
|
|
||
| /** Code diagnostic object is to add system generated comment. It can be one of the 4 different types of system comments. */ | ||
| model CodeDiagnostic { | ||
| /** Id of CodeLine object where this diagnostic needs to be displayed. */ | ||
| lineId: string; | ||
| text: string; | ||
| level: DiagnosticLevel; | ||
| helpLinkUri?: url; | ||
| } | ||
|
|
||
| enum TokenKind { | ||
| Text: 0, | ||
| Punctuation: 1, | ||
| Keyword: 2, | ||
| TypeName: 3, | ||
| MemberName: 4, | ||
| StringLiteral: 5, | ||
| Literal: 6, | ||
| Comment: 7 | ||
| } | ||
|
|
||
| enum DiagnosticLevel { | ||
| Info: 0, | ||
| Warning: 1, | ||
| Error: 2, | ||
| Fatal: 3 | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,170 @@ | ||
| $schema: https://json-schema.org/draft/2020-12/schema | ||
| $id: CodeFile.yaml | ||
| 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 | ||
| - type: string | ||
| const: Kotlin | ||
| - type: string | ||
| const: Python | ||
| - type: string | ||
| const: Swagger | ||
| - type: string | ||
| const: Swift | ||
| - type: string | ||
| const: TypeSpec | ||
| 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 | ||
| crossLanguagePackageId: | ||
| type: string | ||
| codeLines: | ||
| type: array | ||
| items: | ||
| $ref: "#/$defs/CodeLine" | ||
| systemComments: | ||
| type: array | ||
| items: | ||
| $ref: "#/$defs/CodeDiagnostic" | ||
| description: Add any system generated comments for the current token. | ||
| required: | ||
| - packageName | ||
| - packageVersion | ||
| - parserVersion | ||
| - language | ||
| - codeLines | ||
| description: CodeFile represents entire API review object. This will be processed to render review lines. | ||
| $defs: | ||
| CodeLine: | ||
| type: object | ||
| properties: | ||
| lineId: | ||
| type: string | ||
| description: |- | ||
| lineId is only required if we need to support commenting on a line that contains this token. | ||
| Usually code line for documentation or just punctuation is not required to have lineId. lineId should be a unique value within | ||
| the review token file to use it assign to review comments as well as navigation Id within the review page. | ||
| for e.g Azure.Core.HttpHeader.Common, azure.template.template_main | ||
| crossLanguageId: | ||
| type: string | ||
| tokens: | ||
| type: array | ||
| items: | ||
| $ref: "#/$defs/Token" | ||
| description: list of tokens that constructs a line in API review | ||
| children: | ||
| type: array | ||
| items: | ||
| $ref: "#/$defs/CodeLine" | ||
| 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. | ||
| Similarly all method level code lines are added as children of it's class code line. | ||
| required: | ||
| - tokens | ||
| description: Code line 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: | ||
| lineId: | ||
| type: string | ||
| description: Id of CodeLine object where this diagnostic needs to be displayed. | ||
| text: | ||
| type: string | ||
| level: | ||
| $ref: "#/$defs/DiagnosticLevel" | ||
| helpLinkUri: | ||
| type: string | ||
| format: uri | ||
| required: | ||
| - lineId | ||
| - text | ||
| - level | ||
| description: Code diagnostic object is to add system generated comment. It can be one of the 4 different types of system comments. | ||
| Token: | ||
| type: object | ||
| properties: | ||
| kind: | ||
| $ref: "#/$defs/TokenKind" | ||
| value: | ||
| type: string | ||
| navigateToId: | ||
| type: string | ||
| description: |- | ||
| navigateToId should be set if the underlying token is required to be displayed as HREF to another type within the review. | ||
| For e.g. a param type which is class name in the same package | ||
| skipDiff: | ||
| type: boolean | ||
| default: false | ||
| description: |- | ||
| set skipDiff to true if underlying token needs to be ignored from diff calculation. For e.g. package metadata or dependency versions | ||
| are usually not required to be excluded when comparing two revisions to avoid reporting them as API changes | ||
| isHidden: | ||
| type: boolean | ||
| default: false | ||
| description: This is set if API is marked as hidden | ||
| isDeprecated: | ||
| type: boolean | ||
| default: false | ||
| description: This is set if API is marked as deprecated | ||
| hasSuffixSpace: | ||
| type: boolean | ||
| default: true | ||
| description: Set this to false if there is no suffix space required before next token. For e.g, punctuation right after method name | ||
| isDocumentation: | ||
| type: boolean | ||
| default: false | ||
| description: Set isDocumentation to true if current token is part of documentation | ||
| languageStyleClasses: | ||
| type: array | ||
| items: | ||
| type: string | ||
| description: Language specific style css class names | ||
| required: | ||
| - kind | ||
| - value | ||
| description: Token corresponds to each component within a code line. A separate token is required for keyword, punctuation, type name, text etc. | ||
| DiagnosticLevel: | ||
| type: number | ||
| enum: | ||
| - 0 | ||
| - 1 | ||
| - 2 | ||
| - 3 | ||
| TokenKind: | ||
| type: number | ||
| enum: | ||
| - 0 | ||
| - 1 | ||
| - 2 | ||
| - 3 | ||
| - 4 | ||
| - 5 | ||
| - 6 | ||
| - 7 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.