-
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 missing OpenAPI 2.0 semantic tokens (#3508)
Refs #3477
- Loading branch information
Showing
9 changed files
with
306 additions
and
85 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const tokens = [ | ||
'main', | ||
'info', | ||
'principle', | ||
'standard', | ||
'standardIdentifier', | ||
'requirement', | ||
'requirementLevel', | ||
'scenario', | ||
]; | ||
|
||
export default tokens; |
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,45 @@ | ||
const tokens = [ | ||
'parameter', | ||
'api-version', | ||
'spec-version', | ||
'info', | ||
'operation', | ||
'components', | ||
'components-parameters', | ||
'components-schemas', | ||
'components-security-schemes', | ||
'components-messageTraits', | ||
'components-operationTraits', | ||
'components-messages', | ||
'schema', | ||
'server', | ||
'servers', | ||
'server-variables', | ||
'channelItem', | ||
'channels', | ||
'reference-element', | ||
'reference-value', | ||
'channel-binding', | ||
'license', | ||
'message', | ||
'server-url', | ||
'asyncapi-reference', | ||
'json-reference', | ||
'parameters', | ||
'reference', | ||
'contact', | ||
'identifier', | ||
'tags', | ||
'externalDocumentation', | ||
'securityScheme', | ||
'oAuthFlow', | ||
'oAuthFlows', | ||
'discriminator', | ||
'messageTrait', | ||
'messageTraits', | ||
'operationTrait', | ||
'operationTraits', | ||
'security', | ||
]; | ||
|
||
export default tokens; |
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,98 @@ | ||
const openAPI2Tokens = [ | ||
'swagger-host', | ||
'swagger-base-path', | ||
'swagger-schemes', | ||
'swagger-consumes', | ||
'swagger-produces', | ||
'swagger-security', | ||
'swagger-tags', | ||
'definitions', | ||
'parametersDefinitions', | ||
'responsesDefinitions', | ||
'securityDefinitions', | ||
'externalDocumentation', | ||
'info', | ||
'contact', | ||
'license', | ||
'paths', | ||
'pathItem', | ||
'parameters', | ||
'operation', | ||
'operation-consumes', | ||
'operation-produces', | ||
'httpMethod', | ||
'responses', | ||
'security', | ||
'items', | ||
'response', | ||
'headers', | ||
'header', | ||
'tag', | ||
'reference', | ||
'reference-element', | ||
'reference-value', | ||
'openapi-reference', | ||
'json-reference', | ||
'schema', | ||
'xml', | ||
'scopes', | ||
'securityRequirement', | ||
]; | ||
|
||
const openAPI3Tokens = [ | ||
'parameter', | ||
'api-version', | ||
'spec-version', | ||
'info', | ||
'operation', | ||
'pathItem', | ||
'components', | ||
'components-parameters', | ||
'components-schemas', | ||
'components-responses', | ||
'components-examples', | ||
'components-request-bodies', | ||
'components-headers', | ||
'components-security-schemes', | ||
'components-links', | ||
'components-callbacks', | ||
'components-path-items', | ||
'openapi-reference', | ||
'server-url', | ||
'content', | ||
'mediaType', | ||
'openapi', | ||
'parameters', | ||
'paths', | ||
'reference', | ||
'requestBody', | ||
'response', | ||
'responses', | ||
'schema', | ||
'server', | ||
'servers', | ||
'server-variables', | ||
'reference-element', | ||
'reference-value', | ||
'contact', | ||
'httpMethod', | ||
'license', | ||
'tags', | ||
'webhooks', | ||
'jsonSchemaDialect', | ||
'externalDocumentation', | ||
'example', | ||
'examples', | ||
'callback', | ||
'header', | ||
'operation-callbacks', | ||
'securityScheme', | ||
'oAuthFlow', | ||
'oAuthFlows', | ||
'discriminator', | ||
'security', | ||
]; | ||
|
||
const tokens = [...openAPI2Tokens, ...openAPI3Tokens]; | ||
|
||
export default tokens; |
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 |
---|---|---|
@@ -1,83 +1,10 @@ | ||
export default [ | ||
'value', | ||
'string', | ||
'number', | ||
'key', | ||
'parameter', | ||
'api-version', | ||
'spec-version', | ||
'specVersion', | ||
'info', | ||
'operation', | ||
'pathItem', | ||
'components', | ||
'components-parameters', | ||
'components-schemas', | ||
'components-responses', | ||
'components-examples', | ||
'components-request-bodies', | ||
'components-headers', | ||
'components-security-schemes', | ||
'components-links', | ||
'components-callbacks', | ||
'components-path-items', | ||
'components-messageTraits', | ||
'components-operationTraits', | ||
'openapi-reference', | ||
'server-url', | ||
'Asyncapi-reference', | ||
'json-reference', | ||
'content', | ||
'mediaType', | ||
'openapi', | ||
'parameters', | ||
'paths', | ||
'reference', | ||
'requestBody', | ||
'response', | ||
'responses', | ||
'schema', | ||
'server', | ||
'servers', | ||
'server-variables', | ||
'title', | ||
'channelItem', | ||
'channels', | ||
'reference-element', | ||
'reference-value', | ||
'components-messages', | ||
'principle', | ||
'requirement', | ||
'requirementLevel', | ||
'scenario', | ||
'standard', | ||
'standardIdentifier', | ||
'channel-binding', | ||
'contact', | ||
'httpMethod', | ||
'identifier', | ||
'license', | ||
'message', | ||
'tags', | ||
'webhooks', | ||
'jsonSchemaDialect', | ||
'externalDocumentation', | ||
'example', | ||
'examples', | ||
'callback', | ||
'header', | ||
'operation-callbacks', | ||
'securityScheme', | ||
'oAuthFlow', | ||
'oAuthFlows', | ||
'discriminator', | ||
'messageTrait', | ||
'messageTraits', | ||
'operationTrait', | ||
'operationTraits', | ||
'security', | ||
'parametersDefinitions', | ||
'responsesDefinitions', | ||
'parametersDefinitions', | ||
'definitions', | ||
]; | ||
import adsTokens from './ads/tokens'; | ||
import asyncapiTokens from './asyncapi/tokens'; | ||
import openapiTokens from './openapi/tokens'; | ||
|
||
// creating list of unique tokens | ||
const tokens = Array.from( | ||
new Set(['value', 'string', 'number', 'key', ...adsTokens, ...asyncapiTokens, ...openapiTokens]), | ||
); | ||
|
||
export default tokens; |
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
17 changes: 17 additions & 0 deletions
17
packages/apidom-ns-openapi-2/src/refractor/visitors/open-api-2/BasePathVisitor.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,17 @@ | ||
import stampit from 'stampit'; | ||
import { StringElement, BREAK, cloneDeep } from '@swagger-api/apidom-core'; | ||
|
||
import FallbackVisitor from '../FallbackVisitor'; | ||
|
||
const BasePathVisitor = stampit(FallbackVisitor, { | ||
methods: { | ||
StringElement(stringElement: StringElement) { | ||
this.element = cloneDeep(stringElement); | ||
this.element.classes.push('swagger-base-path'); | ||
|
||
return BREAK; | ||
}, | ||
}, | ||
}); | ||
|
||
export default BasePathVisitor; |
17 changes: 17 additions & 0 deletions
17
packages/apidom-ns-openapi-2/src/refractor/visitors/open-api-2/HostVisitor.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,17 @@ | ||
import stampit from 'stampit'; | ||
import { StringElement, BREAK, cloneDeep } from '@swagger-api/apidom-core'; | ||
|
||
import FallbackVisitor from '../FallbackVisitor'; | ||
|
||
const HostVisitor = stampit(FallbackVisitor, { | ||
methods: { | ||
StringElement(stringElement: StringElement) { | ||
this.element = cloneDeep(stringElement); | ||
this.element.classes.push('swagger-host'); | ||
|
||
return BREAK; | ||
}, | ||
}, | ||
}); | ||
|
||
export default HostVisitor; |
Oops, something went wrong.