Skip to content

Commit

Permalink
feat(ls): provide OpenAPI 3.1.0 completion rules for Encoding object (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-lai authored Oct 21, 2022
1 parent de53a13 commit a4618af
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions packages/apidom-ls/src/config/openapi/encoding/completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ const completion: ApidomCompletionItem[] = [
{ namespace: 'openapi', version: '3.0.3' },
],
},
{
label: 'contentType',
insertText: 'contentType',
kind: 14,
format: CompletionFormat.QUOTED,
type: CompletionType.PROPERTY,
insertTextFormat: 2,
documentation: {
kind: 'markdown',
value:
'The Content-Type for encoding a specific property. Default value depends on the property type: for `object` - `application/json`; for `array` – the default is defined based on the inner type; for all other cases the default is `application/octet-stream`. The value can be a specific media type (e.g. `application/json`), a wildcard media type (e.g. `image/*`), or a comma-separated list of the two types.',
},
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
},
{
label: 'headers',
insertText: 'headers',
Expand All @@ -43,6 +57,20 @@ const completion: ApidomCompletionItem[] = [
{ namespace: 'openapi', version: '3.0.3' },
],
},
{
label: 'headers',
insertText: 'headers',
kind: 14,
format: CompletionFormat.OBJECT,
type: CompletionType.PROPERTY,
insertTextFormat: 2,
documentation: {
kind: 'markdown',
value:
'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\\\nA map allowing additional information to be provided as headers, for example `Content-Disposition`. `Content-Type` is described separately and SHALL be ignored in this section. This property SHALL be ignored if the request body media type is not a `multipart`.',
},
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
},
{
label: 'style',
insertText: 'style',
Expand All @@ -62,6 +90,20 @@ const completion: ApidomCompletionItem[] = [
{ namespace: 'openapi', version: '3.0.3' },
],
},
{
label: 'style',
insertText: 'style',
kind: 14,
format: CompletionFormat.QUOTED,
type: CompletionType.PROPERTY,
insertTextFormat: 2,
documentation: {
kind: 'markdown',
value:
'Describes how a specific property value will be serialized depending on its type. See [Parameter Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameterObject) for details on the [`style`](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameterStyle) property. The behavior follows the same values as `query` parameters, including default values. This property SHALL be ignored if the request body media type is not `application/x-www-form-urlencoded` or `multipart/form-data`. If a value is explicitly defined, then the value of [`contentType`](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#encodingContentType) (implicit or explicit) SHALL be ignored.',
},
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
},
{
label: 'explode',
insertText: 'explode',
Expand All @@ -81,6 +123,20 @@ const completion: ApidomCompletionItem[] = [
{ namespace: 'openapi', version: '3.0.3' },
],
},
{
label: 'explode',
insertText: 'explode',
kind: 14,
format: CompletionFormat.UNQUOTED,
type: CompletionType.PROPERTY,
insertTextFormat: 2,
documentation: {
kind: 'markdown',
value:
'When this is true, property 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 properties this property has no effect. When [`style`](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#encodingStyle) is `form`, the default value is `true`. For all other styles, the default value is `false`. This property SHALL be ignored if the request body media type is not `application/x-www-form-urlencoded` or `multipart/form-data`. If a value is explicitly defined, then the value of [`contentType`](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#encodingContentType) (implicit or explicit) SHALL be ignored.',
},
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
},
{
label: 'allowReserved',
insertText: 'allowReserved',
Expand All @@ -100,6 +156,20 @@ const completion: ApidomCompletionItem[] = [
{ namespace: 'openapi', version: '3.0.3' },
],
},
{
label: 'allowReserved',
insertText: 'allowReserved',
kind: 14,
format: CompletionFormat.UNQUOTED,
type: CompletionType.PROPERTY,
insertTextFormat: 2,
documentation: {
kind: 'markdown',
value:
"Determines whether the parameter value SHOULD allow reserved characters, as defined by [RFC3986](https://tools.ietf.org/html/rfc3986#section-2.2) `:/?#[]@!$&'()*+,;=` to be included without percent-encoding. The default value is `false`. This property SHALL be ignored if the request body media type is not `application/x-www-form-urlencoded`.",
},
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
},
];

export default completion;

1 comment on commit a4618af

@char0n
Copy link
Member

@char0n char0n commented on a4618af Oct 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: issued following PR that adds completion for Encoding.style field: #2178

Please sign in to comment.