Skip to content

Commit ce96cce

Browse files
committed
feat(ls): provide OpenAPI 3.0.x Response completion rules
Refs #2032
1 parent 672ed65 commit ce96cce

File tree

2 files changed

+124
-0
lines changed

2 files changed

+124
-0
lines changed
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
import {
2+
ApidomCompletionItem,
3+
CompletionFormat,
4+
CompletionType,
5+
} from '../../../apidom-language-types';
6+
7+
const completion: ApidomCompletionItem[] = [
8+
{
9+
label: 'description',
10+
insertText: 'description',
11+
kind: 14,
12+
format: CompletionFormat.QUOTED,
13+
type: CompletionType.PROPERTY,
14+
insertTextFormat: 2,
15+
documentation: {
16+
kind: 'markdown',
17+
value:
18+
'**REQUIRED**. A description of the response. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.',
19+
},
20+
},
21+
{
22+
label: 'headers',
23+
insertText: 'headers',
24+
kind: 14,
25+
format: CompletionFormat.OBJECT,
26+
type: CompletionType.PROPERTY,
27+
insertTextFormat: 2,
28+
documentation: {
29+
kind: 'markdown',
30+
value:
31+
'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\\\nMaps a header name to its definition. [RFC7230](https://tools.ietf.org/html/rfc7230#page-22) states header names are case insensitive. If a response header is defined with the name `"Content-Type"`, it SHALL be ignored.',
32+
},
33+
targetSpecs: [
34+
{ namespace: 'openapi', version: '3.0.0' },
35+
{ namespace: 'openapi', version: '3.0.1' },
36+
{ namespace: 'openapi', version: '3.0.2' },
37+
{ namespace: 'openapi', version: '3.0.3' },
38+
],
39+
},
40+
{
41+
label: 'headers',
42+
insertText: 'headers',
43+
kind: 14,
44+
format: CompletionFormat.OBJECT,
45+
type: CompletionType.PROPERTY,
46+
insertTextFormat: 2,
47+
documentation: {
48+
kind: 'markdown',
49+
value:
50+
'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\\\nMaps a header name to its definition. [RFC7230](https://tools.ietf.org/html/rfc7230#page-22) states header names are case insensitive. If a response header is defined with the name `"Content-Type"`, it SHALL be ignored.',
51+
},
52+
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
53+
},
54+
{
55+
label: 'content',
56+
insertText: 'content',
57+
kind: 14,
58+
format: CompletionFormat.OBJECT,
59+
type: CompletionType.PROPERTY,
60+
insertTextFormat: 2,
61+
documentation: {
62+
kind: 'markdown',
63+
value:
64+
'Map[`string`, [Media Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#mediaTypeObject)]\n\\\n\\\nA map containing descriptions of potential response payloads. The key is a media type or [media type range](https://tools.ietf.org/html/rfc7231#appendix-D) and the value describes it. For responses that match multiple keys, only the most specific key is applicable. e.g. text/plain overrides text/*',
65+
},
66+
targetSpecs: [
67+
{ namespace: 'openapi', version: '3.0.0' },
68+
{ namespace: 'openapi', version: '3.0.1' },
69+
{ namespace: 'openapi', version: '3.0.2' },
70+
{ namespace: 'openapi', version: '3.0.3' },
71+
],
72+
},
73+
{
74+
label: 'content',
75+
insertText: 'content',
76+
kind: 14,
77+
format: CompletionFormat.OBJECT,
78+
type: CompletionType.PROPERTY,
79+
insertTextFormat: 2,
80+
documentation: {
81+
kind: 'markdown',
82+
value:
83+
'Map[`string`, [Media Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#mediaTypeObject)]\n\\\n\\\nA map containing descriptions of potential response payloads. The key is a media type or [media type range](https://tools.ietf.org/html/rfc7231#appendix-D) and the value describes it. For responses that match multiple keys, only the most specific key is applicable. e.g. text/plain overrides text/*',
84+
},
85+
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
86+
},
87+
{
88+
label: 'links',
89+
insertText: 'links',
90+
kind: 14,
91+
format: CompletionFormat.OBJECT,
92+
type: CompletionType.PROPERTY,
93+
insertTextFormat: 2,
94+
documentation: {
95+
kind: 'markdown',
96+
value:
97+
'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\\\nA map of operations links that can be followed from the response. The key of the map is a short name for the link, following the naming constraints of the names for [Component Objects](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#componentsObject).',
98+
},
99+
targetSpecs: [
100+
{ namespace: 'openapi', version: '3.0.0' },
101+
{ namespace: 'openapi', version: '3.0.1' },
102+
{ namespace: 'openapi', version: '3.0.2' },
103+
{ namespace: 'openapi', version: '3.0.3' },
104+
],
105+
},
106+
{
107+
label: 'links',
108+
insertText: 'links',
109+
kind: 14,
110+
format: CompletionFormat.OBJECT,
111+
type: CompletionType.PROPERTY,
112+
insertTextFormat: 2,
113+
documentation: {
114+
kind: 'markdown',
115+
value:
116+
'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\\\nA map of operations links that can be followed from the response. The key of the map is a short name for the link, following the naming constraints of the names for [Component Objects](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#componentsObject).',
117+
},
118+
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
119+
},
120+
];
121+
122+
export default completion;

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