Skip to content

Commit db7cec5

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

File tree

3 files changed

+324
-1
lines changed

3 files changed

+324
-1
lines changed
Lines changed: 321 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,321 @@
1+
import {
2+
ApidomCompletionItem,
3+
CompletionFormat,
4+
CompletionType,
5+
} from '../../../apidom-language-types';
6+
7+
const completion: ApidomCompletionItem[] = [
8+
{
9+
label: 'schemas',
10+
insertText: 'schemas',
11+
kind: 14,
12+
format: CompletionFormat.OBJECT,
13+
type: CompletionType.PROPERTY,
14+
insertTextFormat: 2,
15+
documentation: {
16+
kind: 'markdown',
17+
value:
18+
'Map[`string`, [Schema Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#schemaObject) \\| [Reference Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#referenceObject)]\n\\\n\\\nAn object to hold reusable [Schema Objects](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#schemaObject).',
19+
},
20+
targetSpecs: [
21+
{ namespace: 'openapi', version: '3.0.0' },
22+
{ namespace: 'openapi', version: '3.0.1' },
23+
{ namespace: 'openapi', version: '3.0.2' },
24+
{ namespace: 'openapi', version: '3.0.3' },
25+
],
26+
},
27+
{
28+
label: 'schemas',
29+
insertText: 'schemas',
30+
kind: 14,
31+
format: CompletionFormat.OBJECT,
32+
type: CompletionType.PROPERTY,
33+
insertTextFormat: 2,
34+
documentation: {
35+
kind: 'markdown',
36+
value:
37+
'Map[`string`, [Schema Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#schemaObject)]\n\\\n\\\nAn object to hold reusable [Schema Objects](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#schemaObject).',
38+
},
39+
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
40+
},
41+
{
42+
label: 'responses',
43+
insertText: 'responses',
44+
kind: 14,
45+
format: CompletionFormat.OBJECT,
46+
type: CompletionType.PROPERTY,
47+
insertTextFormat: 2,
48+
documentation: {
49+
kind: 'markdown',
50+
value:
51+
'Map[`string`, [Response Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#responseObject) | [Reference Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#referenceObject)]\n\\\n\\\nAn object to hold reusable [Response Objects](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#responseObject).',
52+
},
53+
targetSpecs: [
54+
{ namespace: 'openapi', version: '3.0.0' },
55+
{ namespace: 'openapi', version: '3.0.1' },
56+
{ namespace: 'openapi', version: '3.0.2' },
57+
{ namespace: 'openapi', version: '3.0.3' },
58+
],
59+
},
60+
{
61+
label: 'responses',
62+
insertText: 'responses',
63+
kind: 14,
64+
format: CompletionFormat.OBJECT,
65+
type: CompletionType.PROPERTY,
66+
insertTextFormat: 2,
67+
documentation: {
68+
kind: 'markdown',
69+
value:
70+
'Map[`string`, [Response Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#responseObject) | [Reference Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#referenceObject)]\n\\\n\\\nAn object to hold reusable [Response Objects](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#responseObject).',
71+
},
72+
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
73+
},
74+
{
75+
label: 'parameters',
76+
insertText: 'parameters',
77+
kind: 14,
78+
format: CompletionFormat.OBJECT,
79+
type: CompletionType.PROPERTY,
80+
insertTextFormat: 2,
81+
documentation: {
82+
kind: 'markdown',
83+
value:
84+
'Map[`string`, [Parameter Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#parameterObject) | [Reference Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#referenceObject)]\n\\\n\\\nAn object to hold reusable [Parameter Objects](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#parameterObject).',
85+
},
86+
targetSpecs: [
87+
{ namespace: 'openapi', version: '3.0.0' },
88+
{ namespace: 'openapi', version: '3.0.1' },
89+
{ namespace: 'openapi', version: '3.0.2' },
90+
{ namespace: 'openapi', version: '3.0.3' },
91+
],
92+
},
93+
{
94+
label: 'parameters',
95+
insertText: 'parameters',
96+
kind: 14,
97+
format: CompletionFormat.OBJECT,
98+
type: CompletionType.PROPERTY,
99+
insertTextFormat: 2,
100+
documentation: {
101+
kind: 'markdown',
102+
value:
103+
'Map[`string`, [Parameter Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameterObject) | [Reference Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#referenceObject)]\n\\\n\\\nAn object to hold reusable [Parameter Objects](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameterObject).',
104+
},
105+
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
106+
},
107+
{
108+
label: 'examples',
109+
insertText: 'examples',
110+
kind: 14,
111+
format: CompletionFormat.OBJECT,
112+
type: CompletionType.PROPERTY,
113+
insertTextFormat: 2,
114+
documentation: {
115+
kind: 'markdown',
116+
value:
117+
'Map[`string`, [Example Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#exampleObject) | [Reference Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#referenceObject)]\n\\\n\\\nAn object to hold reusable [Example Objects](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#exampleObject).',
118+
},
119+
targetSpecs: [
120+
{ namespace: 'openapi', version: '3.0.0' },
121+
{ namespace: 'openapi', version: '3.0.1' },
122+
{ namespace: 'openapi', version: '3.0.2' },
123+
{ namespace: 'openapi', version: '3.0.3' },
124+
],
125+
},
126+
{
127+
label: 'examples',
128+
insertText: 'examples',
129+
kind: 14,
130+
format: CompletionFormat.OBJECT,
131+
type: CompletionType.PROPERTY,
132+
insertTextFormat: 2,
133+
documentation: {
134+
kind: 'markdown',
135+
value:
136+
'Map[`string`, [Example Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#exampleObject) | [Reference Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#referenceObject)]\n\\\n\\\nAn object to hold reusable [Example Objects](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#exampleObject).',
137+
},
138+
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
139+
},
140+
{
141+
label: 'requestBodies',
142+
insertText: 'requestBodies',
143+
kind: 14,
144+
format: CompletionFormat.OBJECT,
145+
type: CompletionType.PROPERTY,
146+
insertTextFormat: 2,
147+
documentation: {
148+
kind: 'markdown',
149+
value:
150+
'Map[`string`, [Request Body Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#requestBodyObject) | [Reference Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#referenceObject)]\n\\\n\\\nAn object to hold reusable [Request Body Objects](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#requestBodyObject).',
151+
},
152+
targetSpecs: [
153+
{ namespace: 'openapi', version: '3.0.0' },
154+
{ namespace: 'openapi', version: '3.0.1' },
155+
{ namespace: 'openapi', version: '3.0.2' },
156+
{ namespace: 'openapi', version: '3.0.3' },
157+
],
158+
},
159+
{
160+
label: 'requestBodies',
161+
insertText: 'requestBodies',
162+
kind: 14,
163+
format: CompletionFormat.OBJECT,
164+
type: CompletionType.PROPERTY,
165+
insertTextFormat: 2,
166+
documentation: {
167+
kind: 'markdown',
168+
value:
169+
'Map[`string`, [Request Body Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#requestBodyObject) | [Reference Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#referenceObject)]\n\\\n\\\nAn object to hold reusable [Request Body Objects](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#requestBodyObject).',
170+
},
171+
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
172+
},
173+
{
174+
label: 'headers',
175+
insertText: 'headers',
176+
kind: 14,
177+
format: CompletionFormat.OBJECT,
178+
type: CompletionType.PROPERTY,
179+
insertTextFormat: 2,
180+
documentation: {
181+
kind: 'markdown',
182+
value:
183+
'Map[`string`, [Header Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#headerObject) | [Reference Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#referenceObject)]\n\\\n\\\nAn object to hold reusable [Header Objects](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#headerObject).',
184+
},
185+
targetSpecs: [
186+
{ namespace: 'openapi', version: '3.0.0' },
187+
{ namespace: 'openapi', version: '3.0.1' },
188+
{ namespace: 'openapi', version: '3.0.2' },
189+
{ namespace: 'openapi', version: '3.0.3' },
190+
],
191+
},
192+
{
193+
label: 'headers',
194+
insertText: 'headers',
195+
kind: 14,
196+
format: CompletionFormat.OBJECT,
197+
type: CompletionType.PROPERTY,
198+
insertTextFormat: 2,
199+
documentation: {
200+
kind: 'markdown',
201+
value:
202+
'Map[`string`, [Header Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#headerObject) | [Reference Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#referenceObject)]\n\\\n\\\nAn object to hold reusable [Header Objects](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#headerObject).',
203+
},
204+
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
205+
},
206+
{
207+
label: 'securitySchemes',
208+
insertText: 'securitySchemes',
209+
kind: 14,
210+
format: CompletionFormat.OBJECT,
211+
type: CompletionType.PROPERTY,
212+
insertTextFormat: 2,
213+
documentation: {
214+
kind: 'markdown',
215+
value:
216+
'Map[`string`, [Security Scheme Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#securitySchemeObject) | [Reference Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#referenceObject)]\n\\\n\\\nAn object to hold reusable [Security Scheme Objects](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#securitySchemeObject).',
217+
},
218+
targetSpecs: [
219+
{ namespace: 'openapi', version: '3.0.0' },
220+
{ namespace: 'openapi', version: '3.0.1' },
221+
{ namespace: 'openapi', version: '3.0.2' },
222+
{ namespace: 'openapi', version: '3.0.3' },
223+
],
224+
},
225+
{
226+
label: 'securitySchemes',
227+
insertText: 'securitySchemes',
228+
kind: 14,
229+
format: CompletionFormat.OBJECT,
230+
type: CompletionType.PROPERTY,
231+
insertTextFormat: 2,
232+
documentation: {
233+
kind: 'markdown',
234+
value:
235+
'Map[`string`, [Security Scheme Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#securitySchemeObject) | [Reference Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#referenceObject)]\n\\\n\\\nAn object to hold reusable [Security Scheme Objects](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#securitySchemeObject).',
236+
},
237+
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
238+
},
239+
{
240+
label: 'links',
241+
insertText: 'links',
242+
kind: 14,
243+
format: CompletionFormat.OBJECT,
244+
type: CompletionType.PROPERTY,
245+
insertTextFormat: 2,
246+
documentation: {
247+
kind: 'markdown',
248+
value:
249+
'Map[`string`, [Link Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#linkObject) | [Reference Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#referenceObject)]\n\\\n\\\nAn object to hold reusable [Link Objects](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#linkObject).',
250+
},
251+
targetSpecs: [
252+
{ namespace: 'openapi', version: '3.0.0' },
253+
{ namespace: 'openapi', version: '3.0.1' },
254+
{ namespace: 'openapi', version: '3.0.2' },
255+
{ namespace: 'openapi', version: '3.0.3' },
256+
],
257+
},
258+
{
259+
label: 'links',
260+
insertText: 'links',
261+
kind: 14,
262+
format: CompletionFormat.OBJECT,
263+
type: CompletionType.PROPERTY,
264+
insertTextFormat: 2,
265+
documentation: {
266+
kind: 'markdown',
267+
value:
268+
'Map[`string`, [Link Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#linkObject) | [Reference Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#referenceObject)]\n\\\n\\\nAn object to hold reusable [Link Objects](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#linkObject).',
269+
},
270+
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
271+
},
272+
{
273+
label: 'callbacks',
274+
insertText: 'callbacks',
275+
kind: 14,
276+
format: CompletionFormat.OBJECT,
277+
type: CompletionType.PROPERTY,
278+
insertTextFormat: 2,
279+
documentation: {
280+
kind: 'markdown',
281+
value:
282+
'Map[`string`, [Callback Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#callbackObject) | [Reference Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#referenceObject)]\n\\\n\\\nAn object to hold reusable [Callback Objects](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#callbackObject).',
283+
},
284+
targetSpecs: [
285+
{ namespace: 'openapi', version: '3.0.0' },
286+
{ namespace: 'openapi', version: '3.0.1' },
287+
{ namespace: 'openapi', version: '3.0.2' },
288+
{ namespace: 'openapi', version: '3.0.3' },
289+
],
290+
},
291+
{
292+
label: 'callbacks',
293+
insertText: 'callbacks',
294+
kind: 14,
295+
format: CompletionFormat.OBJECT,
296+
type: CompletionType.PROPERTY,
297+
insertTextFormat: 2,
298+
documentation: {
299+
kind: 'markdown',
300+
value:
301+
'Map[`string`, [Callback Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#callbackObject) | [Reference Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#referenceObject)]\n\\\n\\\nAn object to hold reusable [Callback Objects](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#callbackObject).',
302+
},
303+
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
304+
},
305+
{
306+
label: 'pathItems',
307+
insertText: 'pathItems',
308+
kind: 14,
309+
format: CompletionFormat.OBJECT,
310+
type: CompletionType.PROPERTY,
311+
insertTextFormat: 2,
312+
documentation: {
313+
kind: 'markdown',
314+
value:
315+
'Map[`string`, [Path Item Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#pathItemObject) | [Reference Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#referenceObject)]\n\\\n\\\nAn object to hold reusable [Path Item Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#pathItemObject).',
316+
},
317+
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
318+
},
319+
];
320+
321+
export default completion;

packages/apidom-ls/src/config/openapi/components/documentation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ const documentation = [
116116
},
117117
{
118118
target: 'links',
119-
docs: 'Map[`string`, [Link Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#linkObject) | [Reference Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#referenceObject)]\n\\\n\\\nAn object to hold reusable [Link Objects](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#linkObject).',
119+
docs: 'Map[`string`, [Link Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#linkObject) | [Reference Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#referenceObject)]\n\\\n\\\nAn object to hold reusable [Link Objects](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#linkObject).',
120120
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
121121
},
122122
{

packages/apidom-ls/src/config/openapi/components/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)