-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ls): add rules for OpenAPI 2.0 Scopes Object (#3663)
Refs #3620
- Loading branch information
Showing
6 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
10 changes: 10 additions & 0 deletions
10
packages/apidom-ls/src/config/openapi/scopes/documentation.ts
This file contains 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,10 @@ | ||
import { OpenAPI2 } from '../target-specs'; | ||
|
||
const documentation = [ | ||
{ | ||
docs: '#### [Scopes Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#scopes-object)\n\nLists the available scopes for an OAuth2 security scheme.\n\n##### Patterned Fields\n\nField Pattern | Type | Description\n---|:---:|---\n{name} | `string` | Maps between a name of a scope to a short description of it (as the value of the property).\n\n##### Patterned Objects\n\nField Pattern | Type | Description\n---|:---:|---\n^x- | Any | Allows extensions to the Swagger Schema. The field name MUST begin with `x-`, for example, `x-internal-id`. The value can be `null`, a primitive, an array or an object. See [Vendor Extensions](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#vendorExtensions) for further details.\n\n##### Scopes Object Example\n\n```js\n{\n "write:pets": "modify pets in your account",\n "read:pets": "read your pets"\n}\n```\n\n\n\\\nYAML\n```yaml\nwrite:pets: modify pets in your account\nread:pets: read your pets\n```', | ||
targetSpecs: OpenAPI2, | ||
}, | ||
]; | ||
|
||
export default documentation; |
This file contains 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,5 @@ | ||
import valuesTypeLint from './values--type'; | ||
|
||
const lints = [valuesTypeLint]; | ||
|
||
export default lints; |
19 changes: 19 additions & 0 deletions
19
packages/apidom-ls/src/config/openapi/scopes/lint/values--type.ts
This file contains 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,19 @@ | ||
import { DiagnosticSeverity } from 'vscode-languageserver-types'; | ||
|
||
import ApilintCodes from '../../../codes'; | ||
import { LinterMeta } from '../../../../apidom-language-types'; | ||
import { OpenAPI2 } from '../../target-specs'; | ||
|
||
const valuesTypeLint: LinterMeta = { | ||
code: ApilintCodes.OPENAPI2_SCOPES_VALUES_TYPE, | ||
source: 'apilint', | ||
message: 'Scopes Object values must be strings', | ||
severity: DiagnosticSeverity.Error, | ||
linterFunction: 'apilintChildrenOfElementsOrClasses', | ||
linterParams: [['string']], | ||
marker: 'key', | ||
data: {}, | ||
targetSpecs: OpenAPI2, | ||
}; | ||
|
||
export default valuesTypeLint; |
This file contains 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,10 @@ | ||
import lint from './lint'; | ||
import documentation from './documentation'; | ||
import { FormatMeta } from '../../../apidom-language-types'; | ||
|
||
const meta: FormatMeta = { | ||
lint, | ||
documentation, | ||
}; | ||
|
||
export default meta; |