Skip to content

Commit 4994004

Browse files
committed
feat(ls): provide OpenAPI 3.0.x OpenAPI completion rules
Refs #2032
1 parent f2a80ce commit 4994004

File tree

2 files changed

+116
-0
lines changed

2 files changed

+116
-0
lines changed
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
import {
2+
ApidomCompletionItem,
3+
CompletionFormat,
4+
CompletionType,
5+
} from '../../../apidom-language-types';
6+
7+
const completion: ApidomCompletionItem[] = [
8+
{
9+
label: 'openapi',
10+
insertText: 'openapi',
11+
kind: 14,
12+
format: CompletionFormat.QUOTED,
13+
type: CompletionType.PROPERTY,
14+
insertTextFormat: 2,
15+
documentation: {
16+
kind: 'markdown',
17+
value:
18+
'**REQUIRED**. This string MUST be the [semantic version number](https://semver.org/spec/v2.0.0.html) of the [OpenAPI Specification version](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#versions) that the OpenAPI document uses. The `openapi` field SHOULD be used by tooling specifications and clients to interpret the OpenAPI document. This is *not* related to the API [`info.version`](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#infoVersion) string',
19+
},
20+
},
21+
{
22+
label: 'info',
23+
insertText: 'info',
24+
kind: 14,
25+
format: CompletionFormat.OBJECT,
26+
type: CompletionType.PROPERTY,
27+
insertTextFormat: 2,
28+
documentation: {
29+
kind: 'markdown',
30+
value:
31+
'[Info Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#infoObject)\n\\\n\\\n**REQUIRED**. Provides metadata about the API. The metadata MAY be used by tooling as required.',
32+
},
33+
},
34+
{
35+
label: 'servers',
36+
insertText: 'servers',
37+
kind: 14,
38+
format: CompletionFormat.ARRAY,
39+
type: CompletionType.PROPERTY,
40+
insertTextFormat: 2,
41+
documentation: {
42+
kind: 'markdown',
43+
value:
44+
'[[Server Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#serverObject)]\n\\\n\\\nAn array of Server Objects, which provide connectivity information to a target server. If the `servers` property is not provided, or is an empty array, the default value would be a [Server Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#serverObject) with a [url](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#serverUrl) value of `/`.',
45+
},
46+
},
47+
{
48+
label: 'paths',
49+
insertText: 'paths',
50+
kind: 14,
51+
format: CompletionFormat.OBJECT,
52+
type: CompletionType.PROPERTY,
53+
insertTextFormat: 2,
54+
documentation: {
55+
kind: 'markdown',
56+
value:
57+
'[Paths Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#pathsObject)\n\\\n\\\n**REQUIRED**. The available paths and operations for the API.',
58+
},
59+
},
60+
{
61+
label: 'components',
62+
insertText: 'components',
63+
kind: 14,
64+
format: CompletionFormat.OBJECT,
65+
type: CompletionType.PROPERTY,
66+
insertTextFormat: 2,
67+
documentation: {
68+
kind: 'markdown',
69+
value:
70+
'[Components Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#componentsObject)\n\\\n\\\nAn element to hold various schemas for the specification.',
71+
},
72+
},
73+
{
74+
label: 'security',
75+
insertText: 'security',
76+
kind: 14,
77+
format: CompletionFormat.ARRAY,
78+
type: CompletionType.PROPERTY,
79+
insertTextFormat: 2,
80+
documentation: {
81+
kind: 'markdown',
82+
value:
83+
'[[Security Requirement Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#securityRequirementObject)]\n\\\n\\\nA declaration of which security mechanisms can be used across the API. The list of values includes alternative security requirement objects that can be used. Only one of the security requirement objects need to be satisfied to authorize a request. Individual operations can override this definition. To make security optional, an empty security requirement (`{}`) can be included in the array.',
84+
},
85+
},
86+
{
87+
label: 'tags',
88+
insertText: 'tags',
89+
kind: 14,
90+
format: CompletionFormat.ARRAY,
91+
type: CompletionType.PROPERTY,
92+
insertTextFormat: 2,
93+
documentation: {
94+
kind: 'markdown',
95+
value:
96+
"[[Tag Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#tagObject)]\n\\\n\\\nA list of tags used by the specification with additional metadata. The order of the tags can be used to reflect on their order by the parsing tools. Not all tags that are used by the [Operation Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#operationObject) must be declared. The tags that are not declared MAY be organized randomly or based on the tools' logic. Each tag name in the list MUST be unique.",
97+
},
98+
},
99+
{
100+
label: 'externalDocs',
101+
insertText: 'externalDocs',
102+
kind: 14,
103+
format: CompletionFormat.OBJECT,
104+
type: CompletionType.PROPERTY,
105+
insertTextFormat: 2,
106+
documentation: {
107+
kind: 'markdown',
108+
value:
109+
'[External Documentation Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#externalDocumentationObject)\n\\\n\\\nAdditional external documentation.',
110+
},
111+
},
112+
];
113+
114+
export default completion;

packages/apidom-ls/src/config/openapi/openapi3_0/meta.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import completion from './completion';
12
import documentation from './documentation';
23
import { FormatMeta } from '../../../apidom-language-types';
34

45
const meta: FormatMeta = {
6+
completion,
57
documentation,
68
};
79

0 commit comments

Comments
 (0)