Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const documentation = [
{
docs: "#### [Callback Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#callback-object)\n\nA map of possible out-of band callbacks related to the parent operation. Each value in the map is a [Path Item Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#pathItemObject) that describes a set of requests that may be initiated by the API provider and the expected responses. The key value used to identify the path item object is an expression, evaluated at runtime, that identifies a URL to use for the callback operation.\n\n\\\nTo describe incoming requests from the API provider independent from another API call, use the [`webhooks`](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#oasWebhooks) field.\n\n##### Patterned Fields\n\nField Pattern | Type | Description\n---|:---:|---\n{expression} | [Path Item Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#pathItemObject) | [Reference Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#referenceObject) | A Path Item Object, or a reference to one, used to define a callback request and expected responses. A [complete example](https://github.com/OAI/OpenAPI-Specification/blob/main/examples/v3.0/callback-example.yaml) is available.\n\n\\\nThis object MAY be extended with [Specification Extensions](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#specificationExtensions).\n\n##### Key Expression\n\nThe key that identifies the [Path Item Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#pathItemObject) is a [runtime expression](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#runtimeExpression) that can be evaluated in the context of a runtime HTTP request/response to identify the URL to be used for the callback request. A simple example might be `$request.body#/url`. However, using a [runtime expression](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#runtimeExpression) the complete HTTP message can be accessed. This includes accessing any part of a body that a JSON Pointer [RFC6901](https://tools.ietf.org/html/rfc6901) can reference.\n\n\\\nFor example, given the following HTTP request:\n\n\\\nYAML\n```yaml\nPOST /subscribe/myevent?queryUrl=https://clientdomain.com/stillrunning HTTP/1.1\nHost: example.org\nContent-Type: application/json\nContent-Length: 187\n\n{\n \"failedUrl\" : \"https://clientdomain.com/failed\",\n \"successUrls\" : [\n \"https://clientdomain.com/fast\",\n \"https://clientdomain.com/medium\",\n \"https://clientdomain.com/slow\"\n ] \n}\n\n201 Created\nLocation: https://example.org/subscription/1\n```\n\n\\\nThe following examples show how the various expressions evaluate, assuming the callback operation has a path parameter named `eventType` and a query parameter named `queryUrl`.\n\nExpression | Value\n---|:---\n$url | https://example.org/subscribe/myevent?queryUrl=https://clientdomain.com/stillrunning\n$method | POST\n$request.path.eventType | myevent\n$request.query.queryUrl | https://clientdomain.com/stillrunning\n$request.header.content-Type | application/json\n$request.body#/failedUrl | https://clientdomain.com/failed\n$request.body#/successUrls/2 | https://clientdomain.com/medium\n$response.header.Location | https://example.org/subscription/1\n##### Callback Examples\n\nThe following example uses the user provided `queryUrl` query string parameter to define the callback URL. This is an example of how to use a callback object to describe a WebHook callback that goes with the subscription operation to enable registering for the WebHook.\n\n\\\nYAML\n```myCallback:\n '{ $request.query.queryUrl }':\n post:\n requestBody:\n description: Callback payload\n content:\n 'application/json':\n schema:\n $ref: '#/components/schemas/SomePayload'\n responses:\n '200':\n description: callback successfully processed\n```\n\n\\\nThe following example shows a callback where the server is hard-coded, but the query string parameters are populated from the `id` and `email` property in the request body.\n\n\\\nYAML\n```transactionCallback:\n 'http://notificationServer.com?transactionId={$request.body#/id}&email={$request.body#/email}':\n post:\n requestBody:\n description: Callback payload\n content:\n 'application/json':\n schema:\n $ref: '#/components/schemas/SomePayload'\n responses:\n '200':\n description: callback successfully processed\n```\n",
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
},
];

export default documentation;
8 changes: 8 additions & 0 deletions packages/apidom-ls/src/config/openapi/callback/meta.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import documentation from './documentation';
import { FormatMeta } from '../../../apidom-language-types';

const meta: FormatMeta = {
documentation,
};

export default meta;
2 changes: 2 additions & 0 deletions packages/apidom-ls/src/config/openapi/config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import callbackMeta from './callback/meta';
import contactMeta from './contact/meta';
import exampleMeta from './example/meta';
import externalDocumentationMeta from './external-documentation/meta';
Expand Down Expand Up @@ -30,6 +31,7 @@ export default {
},
],
},
callback: callbackMeta,
contact: contactMeta,
example: exampleMeta,
externalDocumentation: externalDocumentationMeta,
Expand Down