Skip to content

Commit 4b437ff

Browse files
authored
feat(ls): provide OpenAPI 3.1.0 completion rules for Parameter object (#2167)
1 parent 6e2fad9 commit 4b437ff

File tree

1 file changed

+98
-0
lines changed

1 file changed

+98
-0
lines changed

packages/apidom-ls/src/config/openapi/parameter/completion.ts

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,20 @@ const completion: ApidomCompletionItem[] = [
3636
{ namespace: 'openapi', version: '3.0.3' },
3737
],
3838
},
39+
{
40+
label: 'name',
41+
insertText: 'name',
42+
kind: 14,
43+
format: CompletionFormat.QUOTED,
44+
type: CompletionType.PROPERTY,
45+
insertTextFormat: 2,
46+
documentation: {
47+
kind: 'markdown',
48+
value:
49+
'**REQUIRED**. The name of the parameter. Parameter names are *case sensitive*.\n\n * If [`in`](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameterIn) is `"path"`, the `name` field MUST correspond to a template expression occurring within the [path](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#pathsPath) field in the [Paths Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#pathsObject). See [Path Templating](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#pathTemplating) for further information.\n\n * If [`in`](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameterIn) is `"header"` and the `name` field is `"Accept"`, `"Content-Type"` or `"Authorization"`, the parameter definition SHALL be ignored.\n\n * For all other cases, the `name` corresponds to the parameter name used by the [`in`](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameterIn) property.',
50+
},
51+
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
52+
},
3953
{
4054
label: 'in',
4155
insertText: 'in',
@@ -81,6 +95,20 @@ const completion: ApidomCompletionItem[] = [
8195
{ namespace: 'openapi', version: '3.0.3' },
8296
],
8397
},
98+
{
99+
label: 'required',
100+
insertText: 'required',
101+
kind: 14,
102+
format: CompletionFormat.UNQUOTED,
103+
type: CompletionType.PROPERTY,
104+
insertTextFormat: 2,
105+
documentation: {
106+
kind: 'markdown',
107+
value:
108+
'Determines whether this parameter is mandatory. If the [parameter location](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameterIn) is `"path"`, this property is **REQUIRED** and its value MUST be `true`. Otherwise, the property MAY be included and its default value is `false`.',
109+
},
110+
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
111+
},
84112
{
85113
label: 'deprecated',
86114
insertText: 'deprecated',
@@ -113,6 +141,20 @@ const completion: ApidomCompletionItem[] = [
113141
{ namespace: 'openapi', version: '3.0.3' },
114142
],
115143
},
144+
{
145+
label: 'allowEmptyValue',
146+
insertText: 'allowEmptyValue',
147+
kind: 14,
148+
format: CompletionFormat.UNQUOTED,
149+
type: CompletionType.PROPERTY,
150+
insertTextFormat: 2,
151+
documentation: {
152+
kind: 'markdown',
153+
value:
154+
'Sets the ability to pass empty-valued parameters. This is valid only for `query` parameters and allows sending a parameter with an empty value. Default value is `false`. If [`style`](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameterStyle) is used, and if behavior is `n/a` (cannot be serialized), the value of `allowEmptyValue` SHALL be ignored. Use of this property is NOT RECOMMENDED, as it is likely to be removed in a later revision.',
155+
},
156+
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
157+
},
116158
{
117159
label: 'style',
118160
insertText: 'style',
@@ -145,6 +187,20 @@ const completion: ApidomCompletionItem[] = [
145187
{ namespace: 'openapi', version: '3.0.3' },
146188
],
147189
},
190+
{
191+
label: 'explode',
192+
insertText: 'explode',
193+
kind: 14,
194+
format: CompletionFormat.UNQUOTED,
195+
type: CompletionType.PROPERTY,
196+
insertTextFormat: 2,
197+
documentation: {
198+
kind: 'markdown',
199+
value:
200+
'When this is true, parameter values of type `array` or `object` generate separate parameters for each value of the array or key-value pair of the map. For other types of parameters this property has no effect. When [`style`](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameterStyle) is `form`, the default value is `true`. For all other styles, the default value is `false`.',
201+
},
202+
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
203+
},
148204
{
149205
label: 'allowReserved',
150206
insertText: 'allowReserved',
@@ -177,6 +233,20 @@ const completion: ApidomCompletionItem[] = [
177233
{ namespace: 'openapi', version: '3.0.3' },
178234
],
179235
},
236+
{
237+
label: 'schema',
238+
insertText: 'schema',
239+
kind: 14,
240+
format: CompletionFormat.OBJECT,
241+
type: CompletionType.PROPERTY,
242+
insertTextFormat: 2,
243+
documentation: {
244+
kind: 'markdown',
245+
value:
246+
'[Schema Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.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.',
247+
},
248+
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
249+
},
180250
{
181251
label: 'example',
182252
insertText: 'example',
@@ -209,6 +279,20 @@ const completion: ApidomCompletionItem[] = [
209279
{ namespace: 'openapi', version: '3.0.3' },
210280
],
211281
},
282+
{
283+
label: 'examples',
284+
insertText: 'examples',
285+
kind: 14,
286+
format: CompletionFormat.OBJECT,
287+
type: CompletionType.PROPERTY,
288+
insertTextFormat: 2,
289+
documentation: {
290+
kind: 'markdown',
291+
value:
292+
"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 parameter 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",
293+
},
294+
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
295+
},
212296
{
213297
label: 'content',
214298
insertText: 'content',
@@ -228,6 +312,20 @@ const completion: ApidomCompletionItem[] = [
228312
{ namespace: 'openapi', version: '3.0.3' },
229313
],
230314
},
315+
{
316+
label: 'content',
317+
insertText: 'content',
318+
kind: 14,
319+
format: CompletionFormat.OBJECT,
320+
type: CompletionType.PROPERTY,
321+
insertTextFormat: 2,
322+
documentation: {
323+
kind: 'markdown',
324+
value:
325+
'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.',
326+
},
327+
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
328+
},
231329
];
232330

233331
export default completion;

0 commit comments

Comments
 (0)