Skip to content

Commit dbcec9b

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

File tree

2 files changed

+108
-0
lines changed

2 files changed

+108
-0
lines changed
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
import {
2+
ApidomCompletionItem,
3+
CompletionFormat,
4+
CompletionType,
5+
} from '../../../apidom-language-types';
6+
7+
const completion: ApidomCompletionItem[] = [
8+
{
9+
label: 'operationRef',
10+
insertText: 'operationRef',
11+
kind: 14,
12+
format: CompletionFormat.QUOTED,
13+
type: CompletionType.PROPERTY,
14+
insertTextFormat: 2,
15+
documentation: {
16+
kind: 'markdown',
17+
value:
18+
'A relative or absolute URI reference to an OAS operation. This field is mutually exclusive of the `operationId` field, and MUST point to an [Operation Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#operationObject). Relative `operationRef` values MAY be used to locate an existing [Operation Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#operationObject) in the OpenAPI definition.',
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: 'operationId',
29+
insertText: 'operationId',
30+
kind: 14,
31+
format: CompletionFormat.QUOTED,
32+
type: CompletionType.PROPERTY,
33+
insertTextFormat: 2,
34+
documentation: {
35+
kind: 'markdown',
36+
value:
37+
'The name of an existing, resolvable OAS operation, as defined with a unique `operationId`. This field is mutually exclusive of the `operationRef` field.',
38+
},
39+
},
40+
{
41+
label: 'parameters',
42+
insertText: 'parameters',
43+
kind: 14,
44+
format: CompletionFormat.OBJECT,
45+
type: CompletionType.PROPERTY,
46+
insertTextFormat: 2,
47+
documentation: {
48+
kind: 'markdown',
49+
value:
50+
'Map[`string`, Any | [`{expression}`](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#runtimeExpression)]\n\\\n\\\nA map representing parameters to pass to an operation as specified with `operationId` or identified via `operationRef`. The key is the parameter name to be used, whereas the value can be a constant or an expression to be evaluated and passed to the linked operation. The parameter name can be qualified using the [parameter location](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#parameterIn) `[{in}.]{name}` for operations that use the same parameter name in different locations (e.g. path.id).',
51+
},
52+
targetSpecs: [
53+
{ namespace: 'openapi', version: '3.0.0' },
54+
{ namespace: 'openapi', version: '3.0.1' },
55+
{ namespace: 'openapi', version: '3.0.2' },
56+
{ namespace: 'openapi', version: '3.0.3' },
57+
],
58+
},
59+
{
60+
label: 'requestBody',
61+
insertText: 'requestBody',
62+
kind: 14,
63+
format: CompletionFormat.QUOTED,
64+
type: CompletionType.PROPERTY,
65+
insertTextFormat: 2,
66+
documentation: {
67+
kind: 'markdown',
68+
value:
69+
'Any | [`{expression}`](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#runtimeExpression)\n\\\n\\\nA literal value or [`{expression}`](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#runtimeExpression) to use as a request body when calling the target operation.',
70+
},
71+
targetSpecs: [
72+
{ namespace: 'openapi', version: '3.0.0' },
73+
{ namespace: 'openapi', version: '3.0.1' },
74+
{ namespace: 'openapi', version: '3.0.2' },
75+
{ namespace: 'openapi', version: '3.0.3' },
76+
],
77+
},
78+
{
79+
label: 'description',
80+
insertText: 'description',
81+
kind: 14,
82+
format: CompletionFormat.QUOTED,
83+
type: CompletionType.PROPERTY,
84+
insertTextFormat: 2,
85+
documentation: {
86+
kind: 'markdown',
87+
value:
88+
'A description of the link. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.',
89+
},
90+
},
91+
{
92+
label: 'server',
93+
insertText: 'server',
94+
kind: 14,
95+
format: CompletionFormat.OBJECT,
96+
type: CompletionType.PROPERTY,
97+
insertTextFormat: 2,
98+
documentation: {
99+
kind: 'markdown',
100+
value:
101+
'[Server Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#serverObject)\n\\\n\\\nA server object to be used by the target operation.',
102+
},
103+
},
104+
];
105+
106+
export default completion;

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