Skip to content

Commit d0b3af6

Browse files
committed
feat(ls): provide OpenAPI 3.0.x Header completion rules
Refs #2032
1 parent 0517cfb commit d0b3af6

File tree

3 files changed

+233
-8
lines changed

3 files changed

+233
-8
lines changed
Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
import {
2+
ApidomCompletionItem,
3+
CompletionFormat,
4+
CompletionType,
5+
} from '../../../apidom-language-types';
6+
7+
const completion: ApidomCompletionItem[] = [
8+
{
9+
label: '$ref',
10+
insertText: '\\$ref',
11+
kind: 14,
12+
format: CompletionFormat.QUOTED,
13+
type: CompletionType.PROPERTY,
14+
insertTextFormat: 2,
15+
documentation: {
16+
kind: 'markdown',
17+
value: 'A reference to a Header',
18+
},
19+
},
20+
{
21+
label: 'description',
22+
insertText: 'description',
23+
kind: 14,
24+
format: CompletionFormat.QUOTED,
25+
type: CompletionType.PROPERTY,
26+
insertTextFormat: 2,
27+
documentation: {
28+
kind: 'markdown',
29+
value:
30+
'A brief description of the header. This could contain examples of use. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.',
31+
},
32+
},
33+
{
34+
label: 'required',
35+
insertText: 'required',
36+
kind: 14,
37+
format: CompletionFormat.UNQUOTED,
38+
type: CompletionType.PROPERTY,
39+
insertTextFormat: 2,
40+
documentation: {
41+
kind: 'markdown',
42+
value:
43+
'Determines whether this header is mandatory. This property MAY be included and its default value is `false`.',
44+
},
45+
},
46+
{
47+
label: 'deprecated',
48+
insertText: 'deprecated',
49+
kind: 14,
50+
format: CompletionFormat.UNQUOTED,
51+
type: CompletionType.PROPERTY,
52+
insertTextFormat: 2,
53+
documentation: {
54+
kind: 'markdown',
55+
value:
56+
'Specifies that a header is deprecated and SHOULD be transitioned out of usage. Default value is `false`.',
57+
},
58+
},
59+
{
60+
label: 'allowEmptyValue',
61+
insertText: 'allowEmptyValue',
62+
kind: 14,
63+
format: CompletionFormat.UNQUOTED,
64+
type: CompletionType.PROPERTY,
65+
insertTextFormat: 2,
66+
documentation: {
67+
kind: 'markdown',
68+
value:
69+
"Doesn't apply for headers. Default value is `false`. Use of this property is NOT RECOMMENDED, as it is likely to be removed in a later revision.",
70+
},
71+
},
72+
{
73+
label: 'style',
74+
insertText: 'style',
75+
kind: 14,
76+
format: CompletionFormat.QUOTED,
77+
type: CompletionType.PROPERTY,
78+
insertTextFormat: 2,
79+
documentation: {
80+
kind: 'markdown',
81+
value: 'Describes how the header value will be serialized. Default value: `simple`.',
82+
},
83+
},
84+
{
85+
label: 'explode',
86+
insertText: 'explode',
87+
kind: 14,
88+
format: CompletionFormat.UNQUOTED,
89+
type: CompletionType.PROPERTY,
90+
insertTextFormat: 2,
91+
documentation: {
92+
kind: 'markdown',
93+
value:
94+
'When this is true, header values of type array or object generate separate headers for each value of the array or key-value pair of the map. The default value is `false`.',
95+
},
96+
},
97+
{
98+
label: 'allowReserved',
99+
insertText: 'allowReserved',
100+
kind: 14,
101+
format: CompletionFormat.UNQUOTED,
102+
type: CompletionType.PROPERTY,
103+
insertTextFormat: 2,
104+
documentation: {
105+
kind: 'markdown',
106+
value:
107+
"Determines whether the header value SHOULD allow reserved characters, as defined by [RFC3986](https://tools.ietf.org/html/rfc3986#section-2.2) `:/?#[]@!$&'()*+,;=` to be included without percent - encoding. This property has no effect and the default value is `false`.",
108+
},
109+
},
110+
{
111+
label: 'schema',
112+
insertText: 'schema',
113+
kind: 14,
114+
format: CompletionFormat.OBJECT,
115+
type: CompletionType.PROPERTY,
116+
insertTextFormat: 2,
117+
documentation: {
118+
kind: 'markdown',
119+
value:
120+
'[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\\\nThe schema defining the type used for the header.',
121+
},
122+
targetSpecs: [
123+
{ namespace: 'openapi', version: '3.0.0' },
124+
{ namespace: 'openapi', version: '3.0.1' },
125+
{ namespace: 'openapi', version: '3.0.2' },
126+
{ namespace: 'openapi', version: '3.0.3' },
127+
],
128+
},
129+
{
130+
label: 'schema',
131+
insertText: 'schema',
132+
kind: 14,
133+
format: CompletionFormat.OBJECT,
134+
type: CompletionType.PROPERTY,
135+
insertTextFormat: 2,
136+
documentation: {
137+
kind: 'markdown',
138+
value:
139+
'[Schema Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#schemaObject)\n\\\n\\\nThe schema defining the type used for the header.',
140+
},
141+
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
142+
},
143+
{
144+
label: 'example',
145+
insertText: 'example',
146+
kind: 14,
147+
format: CompletionFormat.UNDEFINED,
148+
type: CompletionType.PROPERTY,
149+
insertTextFormat: 2,
150+
documentation: {
151+
kind: 'markdown',
152+
value:
153+
"Example of the header's potential value. The example SHOULD match the specified schema and encoding properties if present. The `example` field is mutually exclusive of the `examples` field. Furthermore, if referencing a `schema` that contains an example, the `example` value SHALL *override* the example provided by the schema. To represent examples of media types that cannot naturally be represented in JSON or YAML, a string value can contain the example with escaping where necessary.",
154+
},
155+
},
156+
{
157+
label: 'examples',
158+
insertText: 'examples',
159+
kind: 14,
160+
format: CompletionFormat.OBJECT,
161+
type: CompletionType.PROPERTY,
162+
insertTextFormat: 2,
163+
documentation: {
164+
kind: 'markdown',
165+
value:
166+
"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\\\nExamples of the header's potential value. Each example SHOULD contain a value in the correct format as specified in the header encoding. The `examples` field is mutually exclusive of the `example` field. Furthermore, if referencing a `schema` that contains an example, the `examples` value SHALL *override* the example provided by the schema.",
167+
},
168+
targetSpecs: [
169+
{ namespace: 'openapi', version: '3.0.0' },
170+
{ namespace: 'openapi', version: '3.0.1' },
171+
{ namespace: 'openapi', version: '3.0.2' },
172+
{ namespace: 'openapi', version: '3.0.3' },
173+
],
174+
},
175+
{
176+
label: 'examples',
177+
insertText: 'examples',
178+
kind: 14,
179+
format: CompletionFormat.OBJECT,
180+
type: CompletionType.PROPERTY,
181+
insertTextFormat: 2,
182+
documentation: {
183+
kind: 'markdown',
184+
value:
185+
"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\\\nExamples of the header's potential value. Each example SHOULD contain a value in the correct format as specified in the header encoding. The `examples` field is mutually exclusive of the `example` field. Furthermore, if referencing a `schema` that contains an example, the `examples` value SHALL *override* the example provided by the schema.",
186+
},
187+
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
188+
},
189+
{
190+
label: 'content',
191+
insertText: 'content',
192+
kind: 14,
193+
format: CompletionFormat.OBJECT,
194+
type: CompletionType.PROPERTY,
195+
insertTextFormat: 2,
196+
documentation: {
197+
kind: 'markdown',
198+
value:
199+
'Map[string, [Media Type Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#mediaTypeObject)]\n\\\n\\\nA map containing the representations for the header. The key is the media type and the value describes it. The map MUST only contain one entry.',
200+
},
201+
targetSpecs: [
202+
{ namespace: 'openapi', version: '3.0.0' },
203+
{ namespace: 'openapi', version: '3.0.1' },
204+
{ namespace: 'openapi', version: '3.0.2' },
205+
{ namespace: 'openapi', version: '3.0.3' },
206+
],
207+
},
208+
{
209+
label: 'content',
210+
insertText: 'content',
211+
kind: 14,
212+
format: CompletionFormat.OBJECT,
213+
type: CompletionType.PROPERTY,
214+
insertTextFormat: 2,
215+
documentation: {
216+
kind: 'markdown',
217+
value:
218+
'Map[string, [Media Type Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#mediaTypeObject)]\n\\\n\\\nA map containing the representations for the header. The key is the media type and the value describes it. The map MUST only contain one entry.',
219+
},
220+
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
221+
},
222+
];
223+
224+
export default completion;

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,19 @@
1010
const documentation = [
1111
{
1212
target: 'description',
13-
docs: 'A brief description of the parameter. This could contain examples of use. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.',
13+
docs: 'A brief description of the header. This could contain examples of use. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.',
1414
},
1515
{
1616
target: 'required',
1717
docs: 'Determines whether this header is mandatory. This property MAY be included and its default value is `false`.',
1818
},
1919
{
2020
target: 'deprecated',
21-
docs: 'Specifies that a parameter is deprecated and SHOULD be transitioned out of usage. Default value is `false`.',
21+
docs: 'Specifies that a header is deprecated and SHOULD be transitioned out of usage. Default value is `false`.',
2222
},
2323
{
2424
target: 'allowEmptyValue',
2525
docs: "Doesn't apply for headers. Default value is `false`. Use of this property is NOT RECOMMENDED, as it is likely to be removed in a later revision.",
26-
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
2726
},
2827
{
2928
target: 'style',
@@ -39,7 +38,7 @@ const documentation = [
3938
},
4039
{
4140
target: 'schema',
42-
docs: '[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\\\nThe schema defining the type used for the parameter.',
41+
docs: '[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\\\nThe schema defining the type used for the header.',
4342
targetSpecs: [
4443
{ namespace: 'openapi', version: '3.0.0' },
4544
{ namespace: 'openapi', version: '3.0.1' },
@@ -53,7 +52,7 @@ const documentation = [
5352
},
5453
{
5554
target: 'examples',
56-
docs: "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\\\nExamples of the parameter's potential value. Each example SHOULD contain a value in the correct format as specified in the header encoding. The `examples` field is mutually exclusive of the `example` field. Furthermore, if referencing a `schema` that contains an example, the `examples` value SHALL *override* the example provided by the schema",
55+
docs: "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\\\nExamples of the header's potential value. Each example SHOULD contain a value in the correct format as specified in the header encoding. The `examples` field is mutually exclusive of the `example` field. Furthermore, if referencing a `schema` that contains an example, the `examples` value SHALL *override* the example provided by the schema.",
5756
targetSpecs: [
5857
{ namespace: 'openapi', version: '3.0.0' },
5958
{ namespace: 'openapi', version: '3.0.1' },
@@ -63,12 +62,12 @@ const documentation = [
6362
},
6463
{
6564
target: 'examples',
66-
docs: "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\\\nExamples of the parameter's potential value. Each example SHOULD contain a value in the correct format as specified in the header encoding. The `examples` field is mutually exclusive of the `example` field. Furthermore, if referencing a `schema` that contains an example, the `examples` value SHALL *override* the example provided by the schema",
65+
docs: "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\\\nExamples of the header's potential value. Each example SHOULD contain a value in the correct format as specified in the header encoding. The `examples` field is mutually exclusive of the `example` field. Furthermore, if referencing a `schema` that contains an example, the `examples` value SHALL *override* the example provided by the schema.",
6766
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
6867
},
6968
{
7069
target: 'content',
71-
docs: 'Map[string, [Media Type Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#mediaTypeObject)]\n\\\n\\\nA map containing the representations for the parameter. The key is the media type and the value describes it. The map MUST only contain one entry.',
70+
docs: 'Map[string, [Media Type Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#mediaTypeObject)]\n\\\n\\\nA map containing the representations for the header. The key is the media type and the value describes it. The map MUST only contain one entry.',
7271
targetSpecs: [
7372
{ namespace: 'openapi', version: '3.0.0' },
7473
{ namespace: 'openapi', version: '3.0.1' },
@@ -78,7 +77,7 @@ const documentation = [
7877
},
7978
{
8079
target: 'content',
81-
docs: 'Map[string, [Media Type Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#mediaTypeObject)]\n\\\n\\\nA map containing the representations for the parameter. The key is the media type and the value describes it. The map MUST only contain one entry.',
80+
docs: 'Map[string, [Media Type Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#mediaTypeObject)]\n\\\n\\\nA map containing the representations for the header. The key is the media type and the value describes it. The map MUST only contain one entry.',
8281
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
8382
},
8483
{

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