From 68bc7f06461d97b445f6c7819c0a83d71da49418 Mon Sep 17 00:00:00 2001 From: TharmiganK Date: Fri, 13 Dec 2024 12:15:24 +0530 Subject: [PATCH 1/4] Enable resolver for sanitize sub command --- .../main/java/io/ballerina/openapi/cmd/Flatten.java | 7 ++++--- .../java/io/ballerina/openapi/cmd/Sanitize.java | 8 +++++--- .../java/io/ballerina/openapi/cmd/SubCmdBase.java | 13 +++++++++---- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/openapi-cli/src/main/java/io/ballerina/openapi/cmd/Flatten.java b/openapi-cli/src/main/java/io/ballerina/openapi/cmd/Flatten.java index 2d5394ef4..310856bc0 100644 --- a/openapi-cli/src/main/java/io/ballerina/openapi/cmd/Flatten.java +++ b/openapi-cli/src/main/java/io/ballerina/openapi/cmd/Flatten.java @@ -51,13 +51,14 @@ public class Flatten extends SubCmdBase { private static final String ERROR_OCCURRED_WHILE_GENERATING_SCHEMA_NAMES = "ERROR: error occurred while " + "generating schema names"; + private static final String INFO_MSG_PREFIX = "Flattened"; public Flatten() { - super(CommandType.FLATTEN); + super(CommandType.FLATTEN, INFO_MSG_PREFIX); } public Flatten(PrintStream errorStream, boolean exitWhenFinish) { - super(CommandType.FLATTEN, errorStream, exitWhenFinish); + super(CommandType.FLATTEN, INFO_MSG_PREFIX, errorStream, exitWhenFinish); } @Override @@ -67,7 +68,7 @@ public String getDefaultFileName() { @Override public Optional generate(String openAPIFileContent) { - Optional filteredOpenAPI = getFilteredOpenAPI(openAPIFileContent); + Optional filteredOpenAPI = getFilteredOpenAPI(openAPIFileContent, false); if (filteredOpenAPI.isEmpty()) { return Optional.empty(); } diff --git a/openapi-cli/src/main/java/io/ballerina/openapi/cmd/Sanitize.java b/openapi-cli/src/main/java/io/ballerina/openapi/cmd/Sanitize.java index 70501b633..66dcc2dd5 100644 --- a/openapi-cli/src/main/java/io/ballerina/openapi/cmd/Sanitize.java +++ b/openapi-cli/src/main/java/io/ballerina/openapi/cmd/Sanitize.java @@ -38,12 +38,14 @@ ) public class Sanitize extends SubCmdBase { + private static final String INFO_MSG_PREFIX = "Sanitized"; + public Sanitize() { - super(CommandType.SANITIZE); + super(CommandType.SANITIZE, INFO_MSG_PREFIX); } public Sanitize(PrintStream errorStream, boolean exitWhenFinish) { - super(CommandType.SANITIZE, errorStream, exitWhenFinish); + super(CommandType.SANITIZE, INFO_MSG_PREFIX, errorStream, exitWhenFinish); } @Override @@ -53,7 +55,7 @@ public String getDefaultFileName() { @Override public Optional generate(String openAPIFileContent) { - Optional filteredOpenAPI = getFilteredOpenAPI(openAPIFileContent); + Optional filteredOpenAPI = getFilteredOpenAPI(openAPIFileContent, true); return filteredOpenAPI.flatMap(this::sanitizeOpenAPI); } diff --git a/openapi-cli/src/main/java/io/ballerina/openapi/cmd/SubCmdBase.java b/openapi-cli/src/main/java/io/ballerina/openapi/cmd/SubCmdBase.java index c5322fd7c..391737362 100644 --- a/openapi-cli/src/main/java/io/ballerina/openapi/cmd/SubCmdBase.java +++ b/openapi-cli/src/main/java/io/ballerina/openapi/cmd/SubCmdBase.java @@ -103,6 +103,7 @@ public String getName() { private Path targetPath = Paths.get(System.getProperty("user.dir")); private boolean exitWhenFinish = true; private final CommandType cmdType; + private final String infoMsgPrefix; @CommandLine.Option(names = {"-h", "--help"}, hidden = true) public boolean helpFlag; @@ -125,14 +126,16 @@ public String getName() { @CommandLine.Option(names = {"--operations"}, description = "Operations that need to be included when sanitizing.") public String operations; - protected SubCmdBase(CommandType cmdType) { + protected SubCmdBase(CommandType cmdType, String infoMsgPrefix) { this.cmdType = cmdType; + this.infoMsgPrefix = infoMsgPrefix; } - protected SubCmdBase(CommandType cmdType, PrintStream errorStream, boolean exitWhenFinish) { + protected SubCmdBase(CommandType cmdType, String infoMsgPrefix, PrintStream errorStream, boolean exitWhenFinish) { this.cmdType = cmdType; this.errorStream = errorStream; this.exitWhenFinish = exitWhenFinish; + this.infoMsgPrefix = infoMsgPrefix; } public void printHelpText() { @@ -198,11 +201,13 @@ public Optional getFlattenOpenAPI(OpenAPI openAPI) { return Optional.of(openAPI); } - public Optional getFilteredOpenAPI(String openAPIFileContent) { + public Optional getFilteredOpenAPI(String openAPIFileContent, boolean enableResolver) { // Read the contents of the file with default parser options // Flattening will be done after filtering the operations + ParseOptions parseOptions = new ParseOptions(); + parseOptions.setResolve(enableResolver); SwaggerParseResult parserResult = new OpenAPIParser().readContents(openAPIFileContent, null, - new ParseOptions()); + parseOptions); if (!parserResult.getMessages().isEmpty() && parserResult.getMessages().contains(UNSUPPORTED_OPENAPI_VERSION_PARSER_MESSAGE)) { errorStream.println(ERROR_UNSUPPORTED_OPENAPI_VERSION); From 1d5b3b04fc66fa4a8a9e7f6b8432958a1ef7e03d Mon Sep 17 00:00:00 2001 From: TharmiganK Date: Fri, 13 Dec 2024 12:25:56 +0530 Subject: [PATCH 2/4] Add test case for sanitizing unresolved spec --- .../ballerina/openapi/cmd/OpenAPICmdTest.java | 10 + .../cmd/sanitize/openapi_unresolved.yaml | 1306 +++++++++ ...sanitized_openapi_unresolved_expected.yaml | 2483 +++++++++++++++++ 3 files changed, 3799 insertions(+) create mode 100644 openapi-cli/src/test/resources/cmd/sanitize/openapi_unresolved.yaml create mode 100644 openapi-cli/src/test/resources/cmd/sanitize/sanitized_openapi_unresolved_expected.yaml diff --git a/openapi-cli/src/test/java/io/ballerina/openapi/cmd/OpenAPICmdTest.java b/openapi-cli/src/test/java/io/ballerina/openapi/cmd/OpenAPICmdTest.java index 2ab10554e..5278b47f7 100644 --- a/openapi-cli/src/test/java/io/ballerina/openapi/cmd/OpenAPICmdTest.java +++ b/openapi-cli/src/test/java/io/ballerina/openapi/cmd/OpenAPICmdTest.java @@ -1128,6 +1128,16 @@ public void testSanitizeCmdWithComposedSchema() throws IOException { compareFiles(expectedFilePath, tmpDir.resolve("sanitized_openapi.json")); } + @Test(description = "Test openapi sanitize sub command with unresolved parameter schema") + public void testSanitizeCmdWithUnresolvedParameterSchema() throws IOException { + Path expectedFilePath = resourceDir.resolve(Paths.get("cmd/sanitize/sanitized_openapi_unresolved_expected.yaml")); + String[] args = {"-i", resourceDir + "/cmd/sanitize/openapi_unresolved.yaml", "-o", tmpDir.toString()}; + Sanitize sanitize = new Sanitize(); + new CommandLine(sanitize).parseArgs(args); + sanitize.execute(); + compareFiles(expectedFilePath, tmpDir.resolve("sanitized_openapi.yaml")); + } + @AfterTest public void clean() { System.setErr(null); diff --git a/openapi-cli/src/test/resources/cmd/sanitize/openapi_unresolved.yaml b/openapi-cli/src/test/resources/cmd/sanitize/openapi_unresolved.yaml new file mode 100644 index 000000000..96e88652a --- /dev/null +++ b/openapi-cli/src/test/resources/cmd/sanitize/openapi_unresolved.yaml @@ -0,0 +1,1306 @@ +openapi: 3.0.1 +servers: + - url: https://rest.ably.io +info: + x-ballerina-display: + label: Ably + iconPath: "icon.png" + contact: + email: support@ably.io + name: Ably Support + url: https://www.ably.io/contact + x-twitter: ablyrealtime + description: + This is a generated connector for [Ably REST API v1.1.0](https://ably.com/documentation/rest-api) OpenAPI specification. + + The [Ably REST API](https://www.ably.io/documentation/rest-api) provides a way for a wide range of server and client devices to communicate with the Ably service over REST. + + The REST API does not provide a realtime long-lived connection to Ably, but in all other respects is a simple subset of the full [realtime messaging API](https://ably.com/documentation/realtime). + title: Ably REST API + version: 1.1.0 + x-ballerina-init-description: > + The connector initialization requires setting the API credentials. + + Create an [Ably account](https://ably.com/) and obtain tokens following [this guide](https://ably.com/documentation/core-features/versions/v1.1/authentication). + x-apisguru-categories: + - cloud + x-logo: + url: https://twitter.com/ablyrealtime/profile_image?size=original + x-origin: + - converter: + url: https://github.com/mermade/oas-kit + version: 7.0.4 + format: openapi + url: https://raw.githubusercontent.com/ably/open-specs/main/swagger.yaml + version: "3.0" + x-providerName: ably.io +security: + - basicAuth: [] + - bearerAuth: [] +paths: + /channels: + get: + description: Enumerate all active channels of the application + operationId: getMetadataOfAllChannels + parameters: + - description: Optionally specifies the maximum number of results to return. A limit greater than 1000 is unsupported + in: query + name: limit + schema: + default: 100 + type: integer + - description: Optionally limits the query to only those channels whose name starts with the given prefix + in: query + name: prefix + schema: + type: string + - description: optionally specifies whether to return just channel names (by=id) or ChannelDetails (by=value) + in: query + name: by + schema: + enum: + - value + - id + type: string + responses: + 2XX: + content: + application/json: + schema: + oneOf: + - items: + $ref: "#/components/schemas/ChannelDetails" + type: array + - items: + type: string + type: array + application/x-msgpack: + schema: + oneOf: + - items: + $ref: "#/components/schemas/ChannelDetails" + type: array + - items: + type: string + type: array + text/html: + schema: + type: string + description: OK + headers: + link: + $ref: "#/components/headers/Link" + default: + $ref: "#/components/responses/Error" + summary: Enumerate all active channels of the application + tags: + - Status + parameters: + - $ref: "#/components/parameters/versionHeader" + - $ref: "#/components/parameters/responseFormat" + "/channels/{channel_id}": + get: + description: Get metadata of a channel + operationId: getMetadataOfChannel + parameters: + - $ref: "#/components/parameters/channelId" + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/ChannelDetails" + description: OK + headers: + x-ably-serverid: + $ref: "#/components/headers/ServerId" + default: + $ref: "#/components/responses/Error" + summary: Get metadata of a channel + tags: + - Status + parameters: + - $ref: "#/components/parameters/versionHeader" + - $ref: "#/components/parameters/responseFormat" + "/channels/{channel_id}/messages": + get: + description: Get message history for a channel + operationId: getMessagesByChannel + parameters: + - $ref: "#/components/parameters/channelId" + - $ref: "#/components/parameters/filterStart" + - $ref: "#/components/parameters/filterLimit" + - $ref: "#/components/parameters/filterEnd" + - $ref: "#/components/parameters/filterDirection" + responses: + 2XX: + content: + application/json: + schema: + items: + $ref: "#/components/schemas/Message" + type: array + application/x-msgpack: + schema: + items: + $ref: "#/components/schemas/Message" + type: array + text/html: + schema: + type: string + description: OK + headers: + link: + $ref: "#/components/headers/Link" + x-ably-serverid: + $ref: "#/components/headers/ServerId" + default: + description: Error + headers: + x-ably-errorcode: + $ref: "#/components/headers/ErrorCode" + x-ably-errormessage: + $ref: "#/components/headers/ErrorMessage" + x-ably-serverid: + $ref: "#/components/headers/ServerId" + summary: Get message history for a channel + tags: + - History + parameters: + - $ref: "#/components/parameters/versionHeader" + - $ref: "#/components/parameters/responseFormat" + post: + description: Publish a message to the specified channel + operationId: publishMessagesToChannel + parameters: + - $ref: "#/components/parameters/channelId" + requestBody: + description: Message + content: + application/json: + schema: + $ref: "#/components/schemas/Message" + application/x-msgpack: + schema: + $ref: "#/components/schemas/Message" + application/x-www-form-urlencoded: + schema: + $ref: "#/components/schemas/Message" + responses: + 2XX: + content: + application/json: + schema: + properties: + channel: + type: string + messageId: + type: string + type: object + application/x-msgpack: + schema: + properties: + channel: + type: string + messageId: + type: string + type: object + text/html: + schema: + properties: + channel: + type: string + messageId: + type: string + type: object + description: OK + headers: + x-ably-serverid: + $ref: "#/components/headers/ServerId" + default: + $ref: "#/components/responses/Error" + summary: Publish a message to a channel + tags: + - Publishing + "/channels/{channel_id}/presence": + get: + description: Get presence on a channel + operationId: getPresenceOfChannel + parameters: + - $ref: "#/components/parameters/channelId" + - description: Optional filter to restrict members present with that clientId + in: query + name: clientId + schema: + type: string + - description: Optional filter to restrict members present with that connectionId + in: query + name: connectionId + schema: + type: string + - description: The maximum number of records to return. A limit greater than 1,000 is invalid. + in: query + name: limit + schema: + default: 100 + type: integer + responses: + "200": + content: + application/json: + schema: + items: + $ref: "#/components/schemas/PresenceMessage" + type: array + application/x-msgpack: + schema: + items: + $ref: "#/components/schemas/PresenceMessage" + type: array + text/html: + schema: + type: string + description: OK + headers: + link: + $ref: "#/components/headers/Link" + x-ably-serverid: + $ref: "#/components/headers/ServerId" + default: + $ref: "#/components/responses/Error" + summary: Get presence of a channel + tags: + - Status + parameters: + - $ref: "#/components/parameters/versionHeader" + - $ref: "#/components/parameters/responseFormat" + "/channels/{channel_id}/presence/history": + get: + description: Get presence on a channel + operationId: getPresenceHistoryOfChannel + parameters: + - $ref: "#/components/parameters/channelId" + - $ref: "#/components/parameters/filterStart" + - $ref: "#/components/parameters/filterLimit" + - $ref: "#/components/parameters/filterEnd" + - $ref: "#/components/parameters/filterDirection" + responses: + 2XX: + content: + application/json: + schema: + items: + $ref: "#/components/schemas/PresenceMessage" + type: array + application/x-msgpack: + schema: + items: + $ref: "#/components/schemas/PresenceMessage" + type: array + text/html: + schema: + type: string + description: OK + headers: + link: + $ref: "#/components/headers/Link" + default: + $ref: "#/components/responses/Error" + summary: Get presence history of a channel + tags: + - History + parameters: + - $ref: "#/components/parameters/versionHeader" + - $ref: "#/components/parameters/responseFormat" + "/keys/{keyName}/requestToken": + parameters: + - $ref: "#/components/parameters/versionHeader" + - $ref: "#/components/parameters/responseFormat" + post: + description: This is the means by which clients obtain access tokens to use the service. You can see how to construct an Ably TokenRequest in the [Ably TokenRequest spec](https://www.ably.io/documentation/rest-api/token-request-spec) documentation, although we recommend you use an Ably SDK rather to create a TokenRequest, as the construction of a TokenRequest is complex. The resulting token response object contains the token properties as defined in Ably TokenRequest spec. Authentication is not required if using a Signed TokenRequest. + operationId: requestAccessToken + parameters: + - $ref: "#/components/parameters/key_name" + requestBody: + description: Request Body + content: + application/json: + example: + capability: + channel1: + - publish + - subscribe + wildcard:channels:*: + - publish + keyName: YourKey.Name + timestamp: "1559124196551" + schema: + oneOf: + - $ref: "#/components/schemas/TokenRequest" + - $ref: "#/components/schemas/SignedTokenRequest" + responses: + 2XX: + content: + application/json: + schema: + $ref: "#/components/schemas/TokenDetails" + application/x-msgpack: + schema: + $ref: "#/components/schemas/TokenDetails" + description: OK + default: + $ref: "#/components/responses/Error" + summary: Request an access token + tags: + - Authentication + /push/channelSubscriptions: + delete: + description: Delete a device details object. + operationId: deletePushDeviceDetails + parameters: + - description: Filter to restrict to subscriptions associated with that channel. + in: query + name: channel + schema: + type: string + - description: Must be set when clientId is empty, cannot be used with clientId. + in: query + name: deviceId + schema: + type: string + - description: Must be set when deviceId is empty, cannot be used with deviceId. + in: query + name: clientId + schema: + type: string + responses: + 2XX: + description: OK + default: + $ref: "#/components/responses/Error" + summary: Delete a registered device's update token + tags: + - Push + get: + description: Get a list of push notification subscriptions to channels. + operationId: getPushSubscriptionsOnChannels + parameters: + - description: Filter to restrict to subscriptions associated with that channel. + in: query + name: channel + schema: + type: string + - description: Optional filter to restrict to devices associated with that deviceId. Cannot be used with clientId. + in: query + name: deviceId + schema: + type: string + - description: Optional filter to restrict to devices associated with that clientId. Cannot be used with deviceId. + in: query + name: clientId + schema: + type: string + - description: The maximum number of records to return. + in: query + name: limit + schema: + default: 100 + maximum: 1000 + type: integer + responses: + 2XX: + content: + application/json: + schema: + $ref: "#/components/schemas/DeviceDetails" + description: OK + default: + $ref: "#/components/responses/Error" + summary: List channel subscriptions + tags: + - Push + parameters: + - $ref: "#/components/parameters/versionHeader" + - $ref: "#/components/parameters/responseFormat" + post: + description: Subscribe either a single device or all devices associated with a client ID to receive push notifications from messages sent to a channel. + operationId: subscribePushDeviceToChannel + requestBody: + description: Request Body + content: + application/json: + example: + channel: my:channel + clientId: myClientId + schema: + oneOf: + - properties: + channel: + description: Channel name. + type: string + deviceId: + description: Must be set when clientId is empty, cannot be used with clientId. + type: string + type: object + - properties: + channel: + description: Channel name. + type: string + clientId: + description: Must be set when deviceId is empty, cannot be used with deviceId. + type: string + type: object + application/x-msgpack: + example: + channel: my:channel + clientId: myClientId + schema: + oneOf: + - properties: + channel: + description: Channel name. + type: string + deviceId: + description: Must be set when clientId is empty, cannot be used with clientId. + type: string + type: object + - properties: + channel: + description: Channel name. + type: string + clientId: + description: Must be set when deviceId is empty, cannot be used with deviceId. + type: string + type: object + application/x-www-form-urlencoded: + example: + channel: my:channel + clientId: myClientId + schema: + oneOf: + - properties: + channel: + description: Channel name. + type: string + deviceId: + description: Must be set when clientId is empty, cannot be used with clientId. + type: string + type: object + - properties: + channel: + description: Channel name. + type: string + clientId: + description: Must be set when deviceId is empty, cannot be used with deviceId. + type: string + type: object + responses: + 2XX: + description: OK + default: + $ref: "#/components/responses/Error" + summary: Subscribe a device to a channel + tags: + - Push + /push/channels: + get: + description: Returns a paginated response of channel names. + operationId: getChannelsWithPushSubscribers + responses: + 2XX: + content: + application/json: + schema: + items: + type: string + type: array + application/x-msgpack: + schema: + items: + type: string + type: array + text/html: + schema: + items: + type: string + type: array + description: OK + default: + $ref: "#/components/responses/Error" + summary: List all channels with at least one subscribed device + tags: + - Push + parameters: + - $ref: "#/components/parameters/versionHeader" + - $ref: "#/components/parameters/responseFormat" + /push/deviceRegistrations: + delete: + description: Unregisters devices. All their subscriptions for receiving push notifications through channels will also be deleted. + operationId: unregisterAllPushDevices + parameters: + - description: Optional filter to restrict to devices associated with that deviceId. Cannot be used with clientId. + in: query + name: deviceId + schema: + type: string + - description: Optional filter to restrict to devices associated with that clientId. Cannot be used with deviceId. + in: query + name: clientId + schema: + type: string + responses: + 2XX: + description: OK + default: + $ref: "#/components/responses/Error" + summary: Unregister matching devices for push notifications + tags: + - Push + get: + description: List of device details of devices registed for push notifications. + operationId: getRegisteredPushDevices + parameters: + - description: Optional filter to restrict to devices associated with that deviceId. + in: query + name: deviceId + schema: + type: string + - description: Optional filter to restrict to devices associated with that clientId. + in: query + name: clientId + schema: + type: string + - description: The maximum number of records to return. + in: query + name: limit + schema: + default: 100 + maximum: 1000 + type: integer + responses: + 2XX: + content: + application/json: + schema: + $ref: "#/components/schemas/DeviceDetails" + application/x-msgpack: + schema: + $ref: "#/components/schemas/DeviceDetails" + text/html: + schema: + $ref: "#/components/schemas/DeviceDetails" + description: OK + default: + $ref: "#/components/responses/Error" + summary: List devices registered for receiving push notifications + tags: + - Push + parameters: + - $ref: "#/components/parameters/versionHeader" + - $ref: "#/components/parameters/responseFormat" + post: + description: Register a device’s details, including the information necessary to deliver push notifications to it. Requires "push-admin" capability. + operationId: registerPushDevice + requestBody: + description: Device Details + content: + application/json: + schema: + $ref: "#/components/schemas/DeviceDetails" + application/x-msgpack: + schema: + $ref: "#/components/schemas/DeviceDetails" + responses: + 2XX: + content: + application/json: + schema: + $ref: "#/components/schemas/DeviceDetails" + application/x-msgpack: + schema: + $ref: "#/components/schemas/DeviceDetails" + text/html: + schema: + $ref: "#/components/schemas/DeviceDetails" + description: OK + default: + $ref: "#/components/responses/Error" + summary: Register a device for receiving push notifications + tags: + - Push + "/push/deviceRegistrations/{device_id}": + delete: + description: Unregisters a single device by its device ID. All its subscriptions for receiving push notifications through channels will also be deleted. + operationId: unregisterPushDevice + parameters: + - $ref: "#/components/parameters/deviceId" + responses: + 2XX: + description: OK + default: + $ref: "#/components/responses/Error" + summary: Unregister a single device for push notifications + tags: + - Push + get: + description: Get the full details of a device. + operationId: getPushDeviceDetails + parameters: + - $ref: "#/components/parameters/deviceId" + responses: + 2XX: + content: + application/json: + schema: + $ref: "#/components/schemas/DeviceDetails" + application/x-msgpack: + schema: + $ref: "#/components/schemas/DeviceDetails" + text/html: + schema: + $ref: "#/components/schemas/DeviceDetails" + description: OK + default: + $ref: "#/components/responses/Error" + summary: Get a device registration + tags: + - Push + parameters: + - $ref: "#/components/parameters/versionHeader" + - $ref: "#/components/parameters/responseFormat" + patch: + description: Specific attributes of an existing registration can be updated. Only clientId, metadata and push.recipient are mutable. + operationId: patchPushDeviceDetails + parameters: + - $ref: "#/components/parameters/deviceId" + requestBody: + description: Device Details + content: + application/json: + schema: + $ref: "#/components/schemas/DeviceDetails" + application/x-msgpack: + schema: + $ref: "#/components/schemas/DeviceDetails" + application/x-www-form-urlencoded: + schema: + $ref: "#/components/schemas/DeviceDetails" + responses: + 2XX: + content: + application/json: + schema: + $ref: "#/components/schemas/DeviceDetails" + application/x-msgpack: + schema: + $ref: "#/components/schemas/DeviceDetails" + text/html: + schema: + $ref: "#/components/schemas/DeviceDetails" + description: OK + default: + $ref: "#/components/responses/Error" + summary: Update a device registration + tags: + - Push + put: + description: Device registrations can be upserted (the existing registration is replaced entirely) with a PUT operation. Only clientId, metadata and push.recipient are mutable. + operationId: putPushDeviceDetails + parameters: + - $ref: "#/components/parameters/deviceId" + requestBody: + description: Device Details + content: + application/json: + schema: + $ref: "#/components/schemas/DeviceDetails" + application/x-msgpack: + schema: + $ref: "#/components/schemas/DeviceDetails" + application/x-www-form-urlencoded: + schema: + $ref: "#/components/schemas/DeviceDetails" + responses: + 2XX: + content: + application/json: + schema: + $ref: "#/components/schemas/DeviceDetails" + application/x-msgpack: + schema: + $ref: "#/components/schemas/DeviceDetails" + text/html: + schema: + $ref: "#/components/schemas/DeviceDetails" + description: OK + default: + $ref: "#/components/responses/Error" + summary: Update a device registration + tags: + - Push + "/push/deviceRegistrations/{device_id}/resetUpdateToken": + get: + description: Gets an updated device details object. + operationId: updatePushDeviceDetails + parameters: + - $ref: "#/components/parameters/deviceId" + responses: + 2XX: + content: + application/json: + schema: + $ref: "#/components/schemas/DeviceDetails" + application/x-msgpack: + schema: + $ref: "#/components/schemas/DeviceDetails" + text/html: + schema: + $ref: "#/components/schemas/DeviceDetails" + description: OK + default: + $ref: "#/components/responses/Error" + summary: Reset a registered device's update token + tags: + - Push + parameters: + - $ref: "#/components/parameters/versionHeader" + - $ref: "#/components/parameters/responseFormat" + /push/publish: + parameters: + - $ref: "#/components/parameters/versionHeader" + - $ref: "#/components/parameters/responseFormat" + post: + description: A convenience endpoint to deliver a push notification payload to a single device or set of devices identified by their client identifier. + operationId: publishPushNotificationToDevices + requestBody: + description: Request Body + content: + application/json: + schema: + properties: + push: + $ref: "#/components/schemas/Push" + recipient: + $ref: "#/components/schemas/Recipient" + required: + - recipient + type: object + application/x-msgpack: + schema: + properties: + push: + $ref: "#/components/schemas/Push" + recipient: + $ref: "#/components/schemas/Recipient" + required: + - recipient + type: object + application/x-www-form-urlencoded: + schema: + properties: + push: + $ref: "#/components/schemas/Push" + recipient: + $ref: "#/components/schemas/Recipient" + required: + - recipient + type: object + responses: + 2XX: + description: OK + default: + $ref: "#/components/responses/Error" + summary: Publish a push notification to device(s) + tags: + - Push + /stats: + get: + description: The Ably system can be queried to obtain usage statistics for a given application, and results are provided aggregated across all channels in use in the application in the specified period. Stats may be used to track usage against account quotas. + operationId: getStats + parameters: + - $ref: "#/components/parameters/filterStart" + - $ref: "#/components/parameters/filterLimit" + - $ref: "#/components/parameters/filterEnd" + - $ref: "#/components/parameters/filterDirection" + - description: Specifies the unit of aggregation in the returned results. + in: query + name: unit + schema: + default: minute + enum: + - minute + - hour + - day + - month + type: string + responses: + 2XX: + content: + application/json: + schema: + type: object + description: OK + default: + $ref: "#/components/responses/Error" + summary: Retrieve usage statistics for an application + tags: + - Stats + parameters: + - $ref: "#/components/parameters/versionHeader" + - $ref: "#/components/parameters/responseFormat" + /time: + get: + description: This returns the service time in milliseconds since the epoch. + operationId: getTime + responses: + 2XX: + content: + application/json: + schema: + items: + type: integer + type: array + application/x-msgpack: + schema: + items: + type: integer + type: array + text/html: + schema: + type: string + description: OK + default: + $ref: "#/components/responses/Error" + security: [] + summary: Get the service time + tags: + - Stats + parameters: + - $ref: "#/components/parameters/versionHeader" + - $ref: "#/components/parameters/responseFormat" +components: + headers: + ErrorCode: + description: The error code. + schema: + type: integer + ErrorMessage: + description: The error message. + schema: + type: string + Link: + description: Links to related resources, in the format defined by [RFC 5988](https://tools.ietf.org/html/rfc5988#section-5). This will potentially include a link with relation type `next`, `first`, and `current`, where appropiate. + required: true + schema: + pattern: (<(.*)?>; rel=\"(first|current|last)?\",)*(<(.*)?>; rel=\"(first|current|last)?\")+ + type: string + ServerId: + description: The ID for the server communicated with. + required: true + schema: + type: string + parameters: + channelId: + description: The [Channel's ID](https://www.ably.io/documentation/rest/channels). + in: path + name: channel_id + required: true + schema: + type: string + deviceId: + description: Device's ID. + in: path + name: device_id + required: true + schema: + type: string + filterDirection: + description: The direction of this query. The direction determines the order of the returned result array, but also determines which end of the query interval is the start point for the search. For example, a forwards query uses start as the start point, whereas a backwards query uses end as the start point. + in: query + name: direction + schema: + default: backwards + enum: + - forwards + - backwards + type: string + filterEnd: + description: The end of the query interval as a time in milliseconds since the epoch. A message qualifies as a member of the result set if it was received at or before this time. + in: query + name: end + schema: + default: now + type: string + filterLimit: + description: The maximum number of records to return. A limit greater than 1,000 is invalid. + in: query + name: limit + schema: + default: "100" + type: integer + filterStart: + description: Beginning of time The start of the query interval as a time in milliseconds since the epoch. A message qualifies as a member of the result set if it was received at or after this time. + in: query + name: start + schema: + type: string + key_name: + description: The [key name](https://www.ably.io/documentation/rest-api/token-request-spec#api-key-format) comprises of the app ID and key ID of an API key. + in: path + name: keyName + required: true + schema: + type: string + responseFormat: + description: The response format you would like + in: query + name: format + schema: + enum: + - json + - jsonp + - msgpack + - html + type: string + versionHeader: + description: The version of the API you wish to use. + in: header + name: X-Ably-Version + schema: + type: string + responses: + Error: + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + application/x-msgpack: + schema: + $ref: "#/components/schemas/Error" + text/html: + schema: + $ref: "#/components/schemas/Error" + description: Error + headers: + x-ably-errorcode: + $ref: "#/components/headers/ErrorCode" + x-ably-errormessage: + $ref: "#/components/headers/ErrorMessage" + x-ably-serverid: + $ref: "#/components/headers/ServerId" + schemas: + ChannelDetails: + properties: + channelId: + description: The required name of the channel including any qualifier, if any. + type: string + isGlobalMaster: + description: In events relating to the activity of a channel in a specific region, this optionally identifies whether or not that region is responsible for global coordination of the channel. + type: boolean + region: + description: In events relating to the activity of a channel in a specific region, this optionally identifies the region. + type: string + status: + $ref: "#/components/schemas/ChannelStatus" + required: + - channelId + type: object + ChannelStatus: + description: A ChannelStatus instance. + properties: + isActive: + description: A required boolean value indicating whether the channel that is the subject of the event is active. For events indicating regional activity of a channel this indicates activity in that region, not global activity. + type: boolean + occupancy: + $ref: "#/components/schemas/Occupancy" + required: + - isActive + type: object + DeviceDetails: + properties: + clientId: + description: Optional trusted client identifier for the device. + type: string + deviceSecret: + description: Secret value for the device. + type: string + formFactor: + description: Form factor of the push device. + enum: + - phone + - tablet + - desktop + - tv + - watch + - car + - embedded + type: string + id: + description: Unique identifier for the device generated by the device itself. + type: string + metadata: + description: Optional metadata object for this device. The metadata for a device may only be set by clients with push-admin privileges and will be used more extensively in the future with smart notifications. + type: object + platform: + description: Platform of the push device. + enum: + - ios + - android + type: string + pushRecipient: + $ref: "#/components/schemas/Recipient" + pushState: + description: the current state of the push device. + enum: + - Active + - Failing + - Failed + readOnly: true + type: string + type: object + Error: + description: Returned error from failed REST. + properties: + code: + description: Error code. + type: integer + href: + description: Link to help with error. + type: string + message: + description: Message explaining the error's cause. + type: string + serverId: + description: Server ID with which error was encountered. + type: string + statusCode: + description: Status error code. + type: integer + type: object + Extras: + description: Extras object. Currently only allows for [push](https://www.ably.io/documentation/general/push/publish#channel-broadcast-example) extra. + properties: + push: + $ref: "#/components/schemas/Push" + type: object + Message: + description: Message object. + properties: + clientId: + description: The [client ID](https://www.ably.io/documentation/core-features/authentication#identified-clients) of the publisher of this message. + type: string + connectionId: + description: The connection ID of the publisher of this message. + type: string + data: + description: The string encoded payload, with the encoding specified below. + type: string + encoding: + description: This will typically be empty as all messages received from Ably are automatically decoded client-side using this value. However, if the message encoding cannot be processed, this attribute will contain the remaining transformations not applied to the data payload. + type: string + extras: + $ref: "#/components/schemas/Extras" + id: + description: A Unique ID that can be specified by the publisher for [idempotent publishing](https://www.ably.io/documentation/rest/messages#idempotent). + readOnly: true + type: string + name: + description: The event name, if provided. + type: string + timestamp: + description: Timestamp when the message was received by the Ably, as milliseconds since the epoch. + format: int64 + readOnly: true + type: integer + type: object + Notification: + description: Notification + properties: + body: + description: Text below title on the expanded notification. + type: string + collapseKey: + description: Platform-specific, used to group notifications together. + type: string + icon: + description: Platform-specific icon for the notification. + type: string + sound: + description: Platform-specific sound for the notification. + type: string + title: + description: Title to display at the notification. + type: string + type: object + Occupancy: + description: An Occupancy instance indicating the occupancy of a channel. For events indicating regional activity of a channel this indicates activity in that region, not global activity. + properties: + presenceConnections: + description: The number of connections that are authorised to enter members into the presence channel. + type: integer + presenceMembers: + description: The number of members currently entered into the presence channel. + type: integer + presenceSubscribers: + description: The number of connections that are authorised to subscribe to presence messages. + type: integer + publishers: + description: The number of connections attached to the channel that are authorised to publish. + type: integer + subscribers: + description: The number of connections attached that are authorised to subscribe to messages. + type: integer + type: object + PresenceMessage: + properties: + action: + description: The event signified by a PresenceMessage. + enum: + - ABSENT + - PRESENT + - ENTER + - LEAVE + - UPDATE + readOnly: true + type: string + clientId: + description: The client ID of the publisher of this presence update. + type: string + connectionId: + description: The connection ID of the publisher of this presence update. + type: string + data: + description: The presence update payload, if provided. + type: string + encoding: + description: This will typically be empty as all presence updates received from Ably are automatically decoded client-side using this value. However, if the message encoding cannot be processed, this attribute will contain the remaining transformations not applied to the data payload. + type: string + extras: + $ref: "#/components/schemas/Extras" + id: + description: Unique ID assigned by Ably to this presence update. + readOnly: true + type: string + timestamp: + description: Timestamp when the presence update was received by Ably, as milliseconds since the epoch. + format: int64 + readOnly: true + type: integer + type: object + Push: + description: Push + properties: + apns: + description: Extends and overrides generic values when delivering via APNs. [See examples](https://www.ably.io/documentation/general/push/publish#payload-structure) + properties: + notification: + $ref: "#/components/schemas/Notification" + type: object + data: + description: Arbitrary [key-value string-to-string payload](https://www.ably.io/documentation/general/push/publish#channel-broadcast-example). + type: string + fcm: + description: Extends and overrides generic values when delivering via GCM/FCM. [See examples](https://www.ably.io/documentation/general/push/publish#payload-structure) + properties: + notification: + $ref: "#/components/schemas/Notification" + type: object + notification: + $ref: "#/components/schemas/Notification" + web: + description: Extends and overrides generic values when delivering via web. [See examples](https://www.ably.io/documentation/general/push/publish#payload-structure) + properties: + notification: + $ref: "#/components/schemas/Notification" + type: object + type: object + Recipient: + description: Push recipient details for a device. + properties: + clientId: + description: Client ID of recipient + type: string + writeOnly: true + deviceId: + description: Client ID of recipient + type: string + writeOnly: true + deviceToken: + description: when using APNs, specifies the required device token. + type: string + registrationToken: + description: when using GCM or FCM, specifies the required registration token. + type: string + transportType: + description: Defines which push platform is being used. + enum: + - apns + - fcm + - gcm + type: string + type: object + SignedTokenRequest: + allOf: + - $ref: "#/components/schemas/TokenRequest" + - properties: + mac: + description: A signature, generated as an HMAC of each of the above components, using the key secret value. + type: string + required: + - mac + type: object + TokenDetails: + properties: + capability: + description: Regular expression representation of the capabilities of the token. + type: string + expires: + description: Timestamp of token expiration. + type: integer + issued: + description: Timestamp of token creation. + type: integer + keyName: + description: Name of the key used to create the token + type: string + token: + description: The Ably Token. + type: string + type: object + TokenRequest: + properties: + capability: + description: The [capabilities](https://www.ably.io/documentation/core-features/authentication#capabilities-explained) (i.e. a set of channel names/namespaces and, for each, a set of operations) which should be a subset of the set of capabilities associated with the key specified in keyName. + example: + channel1: + - publish + - subscribe + type: object + clientId: + description: The [client ID](https://www.ably.io/documentation/core-features/authentication#identified-clients) to be assosciated with the token. Can be set to * to allow for any client ID to be used. + type: string + keyName: + description: Name of the key used for the TokenRequest. The keyName comprises of the app ID and key ID on an API Key. + example: xVLyHw.LMJZxw + type: string + nonce: + description: An unquoted, un-escaped random string of at least 16 characters. Used to ensure the Ably TokenRequest cannot be reused. + type: string + timestamp: + description: Time of creation of the Ably TokenRequest. + type: integer + required: + - keyName + - capability + - timestamp + - nonce + type: object + securitySchemes: + basicAuth: + description: Basic Authentication using an [API key](https://www.ably.io/documentation/core-features/authentication#basic-authentication). + scheme: basic + type: http + bearerAuth: + description: Token Authentication using an [Ably Token](https://www.ably.io/documentation/core-features/authentication#basic-authentication), or optionally an [Ably JWT](https://www.ably.io/documentation/core-features/authentication#ably-jwt-process). + scheme: bearer + type: http diff --git a/openapi-cli/src/test/resources/cmd/sanitize/sanitized_openapi_unresolved_expected.yaml b/openapi-cli/src/test/resources/cmd/sanitize/sanitized_openapi_unresolved_expected.yaml new file mode 100644 index 000000000..1d3db985d --- /dev/null +++ b/openapi-cli/src/test/resources/cmd/sanitize/sanitized_openapi_unresolved_expected.yaml @@ -0,0 +1,2483 @@ +openapi: 3.0.1 +info: + title: Ably REST API + description: |- + This is a generated connector for [Ably REST API v1.1.0](https://ably.com/documentation/rest-api) OpenAPI specification. + The [Ably REST API](https://www.ably.io/documentation/rest-api) provides a way for a wide range of server and client devices to communicate with the Ably service over REST. + The REST API does not provide a realtime long-lived connection to Ably, but in all other respects is a simple subset of the full [realtime messaging API](https://ably.com/documentation/realtime). + contact: + name: Ably Support + url: https://www.ably.io/contact + email: support@ably.io + x-twitter: ablyrealtime + version: 1.1.0 + x-ballerina-display: + label: Ably + iconPath: icon.png + x-ballerina-init-description: "The connector initialization requires setting the\ + \ API credentials. \nCreate an [Ably account](https://ably.com/) and obtain tokens\ + \ following [this guide](https://ably.com/documentation/core-features/versions/v1.1/authentication).\n" + x-apisguru-categories: + - cloud + x-logo: + url: https://twitter.com/ablyrealtime/profile_image?size=original + x-origin: + - converter: + url: https://github.com/mermade/oas-kit + version: 7.0.4 + format: openapi + url: https://raw.githubusercontent.com/ably/open-specs/main/swagger.yaml + version: "3.0" + x-providerName: ably.io +servers: + - url: https://rest.ably.io +security: + - basicAuth: [] + - bearerAuth: [] +paths: + /channels: + get: + tags: + - Status + summary: Enumerate all active channels of the application + description: Enumerate all active channels of the application + operationId: getMetadataOfAllChannels + parameters: + - name: X-Ably-Version + in: header + description: The version of the API you wish to use. + required: false + style: simple + explode: false + schema: + type: string + x-ballerina-name: xAblyVersion + - name: format + in: query + description: The response format you would like + required: false + style: form + explode: true + schema: + type: string + enum: + - json + - jsonp + - msgpack + - html + - name: limit + in: query + description: Optionally specifies the maximum number of results to return. + A limit greater than 1000 is unsupported + required: false + style: form + explode: true + schema: + type: integer + default: 100 + - name: prefix + in: query + description: Optionally limits the query to only those channels whose name + starts with the given prefix + required: false + style: form + explode: true + schema: + type: string + - name: by + in: query + description: optionally specifies whether to return just channel names (by=id) + or ChannelDetails (by=value) + required: false + style: form + explode: true + schema: + type: string + enum: + - value + - id + responses: + "2XX": + description: OK + headers: + link: + $ref: "#/components/headers/Link" + content: + application/json: + schema: + oneOf: + - type: array + items: + $ref: "#/components/schemas/ChannelDetails" + - type: array + items: + type: string + application/x-msgpack: + schema: + oneOf: + - type: array + items: + $ref: "#/components/schemas/ChannelDetails" + - type: array + items: + type: string + text/html: + schema: + type: string + default: + description: Error + headers: + x-ably-errorcode: + $ref: "#/components/headers/ErrorCode" + x-ably-errormessage: + $ref: "#/components/headers/ErrorMessage" + x-ably-serverid: + $ref: "#/components/headers/ServerId" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + application/x-msgpack: + schema: + $ref: "#/components/schemas/Error" + text/html: + schema: + $ref: "#/components/schemas/Error" + /channels/{channelId}: + get: + tags: + - Status + summary: Get metadata of a channel + description: Get metadata of a channel + operationId: getMetadataOfChannel + parameters: + - name: X-Ably-Version + in: header + description: The version of the API you wish to use. + required: false + style: simple + explode: false + schema: + type: string + x-ballerina-name: xAblyVersion + - name: format + in: query + description: The response format you would like + required: false + style: form + explode: true + schema: + type: string + enum: + - json + - jsonp + - msgpack + - html + - name: channelId + in: path + description: "The [Channel's ID](https://www.ably.io/documentation/rest/channels)." + required: true + style: simple + explode: false + schema: + type: string + responses: + "200": + description: OK + headers: + x-ably-serverid: + $ref: "#/components/headers/ServerId" + content: + application/json: + schema: + $ref: "#/components/schemas/ChannelDetails" + default: + description: Error + headers: + x-ably-errorcode: + $ref: "#/components/headers/ErrorCode" + x-ably-errormessage: + $ref: "#/components/headers/ErrorMessage" + x-ably-serverid: + $ref: "#/components/headers/ServerId" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + application/x-msgpack: + schema: + $ref: "#/components/schemas/Error" + text/html: + schema: + $ref: "#/components/schemas/Error" + /channels/{channelId}/messages: + get: + tags: + - History + summary: Get message history for a channel + description: Get message history for a channel + operationId: getMessagesByChannel + parameters: + - name: X-Ably-Version + in: header + description: The version of the API you wish to use. + required: false + style: simple + explode: false + schema: + type: string + x-ballerina-name: xAblyVersion + - name: format + in: query + description: The response format you would like + required: false + style: form + explode: true + schema: + type: string + enum: + - json + - jsonp + - msgpack + - html + - name: channelId + in: path + description: "The [Channel's ID](https://www.ably.io/documentation/rest/channels)." + required: true + style: simple + explode: false + schema: + type: string + - name: start + in: query + description: Beginning of time The start of the query interval as a time in + milliseconds since the epoch. A message qualifies as a member of the result + set if it was received at or after this time. + required: false + style: form + explode: true + schema: + type: string + - name: limit + in: query + description: "The maximum number of records to return. A limit greater than\ + \ 1,000 is invalid." + required: false + style: form + explode: true + schema: + type: integer + - name: end + in: query + description: The end of the query interval as a time in milliseconds since + the epoch. A message qualifies as a member of the result set if it was received + at or before this time. + required: false + style: form + explode: true + schema: + type: string + default: now + - name: direction + in: query + description: "The direction of this query. The direction determines the order\ + \ of the returned result array, but also determines which end of the query\ + \ interval is the start point for the search. For example, a forwards query\ + \ uses start as the start point, whereas a backwards query uses end as the\ + \ start point." + required: false + style: form + explode: true + schema: + type: string + default: backwards + enum: + - forwards + - backwards + responses: + "2XX": + description: OK + headers: + link: + $ref: "#/components/headers/Link" + x-ably-serverid: + $ref: "#/components/headers/ServerId" + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/Message" + application/x-msgpack: + schema: + type: array + items: + $ref: "#/components/schemas/Message" + text/html: + schema: + type: string + default: + description: Error + headers: + x-ably-errorcode: + $ref: "#/components/headers/ErrorCode" + x-ably-errormessage: + $ref: "#/components/headers/ErrorMessage" + x-ably-serverid: + $ref: "#/components/headers/ServerId" + post: + tags: + - Publishing + summary: Publish a message to a channel + description: Publish a message to the specified channel + operationId: publishMessagesToChannel + parameters: + - name: X-Ably-Version + in: header + description: The version of the API you wish to use. + required: false + style: simple + explode: false + schema: + type: string + x-ballerina-name: xAblyVersion + - name: format + in: query + description: The response format you would like + required: false + style: form + explode: true + schema: + type: string + enum: + - json + - jsonp + - msgpack + - html + - name: channelId + in: path + description: "The [Channel's ID](https://www.ably.io/documentation/rest/channels)." + required: true + style: simple + explode: false + schema: + type: string + requestBody: + description: Message + content: + application/json: + schema: + $ref: "#/components/schemas/Message" + application/x-msgpack: + schema: + $ref: "#/components/schemas/Message" + application/x-www-form-urlencoded: + schema: + $ref: "#/components/schemas/Message" + responses: + "2XX": + description: OK + headers: + x-ably-serverid: + $ref: "#/components/headers/ServerId" + content: + application/json: + schema: + type: object + properties: + channel: + type: string + messageId: + type: string + application/x-msgpack: + schema: + type: object + properties: + channel: + type: string + messageId: + type: string + text/html: + schema: + type: object + properties: + channel: + type: string + messageId: + type: string + default: + description: Error + headers: + x-ably-errorcode: + $ref: "#/components/headers/ErrorCode" + x-ably-errormessage: + $ref: "#/components/headers/ErrorMessage" + x-ably-serverid: + $ref: "#/components/headers/ServerId" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + application/x-msgpack: + schema: + $ref: "#/components/schemas/Error" + text/html: + schema: + $ref: "#/components/schemas/Error" + /channels/{channelId}/presence: + get: + tags: + - Status + summary: Get presence of a channel + description: Get presence on a channel + operationId: getPresenceOfChannel + parameters: + - name: X-Ably-Version + in: header + description: The version of the API you wish to use. + required: false + style: simple + explode: false + schema: + type: string + x-ballerina-name: xAblyVersion + - name: format + in: query + description: The response format you would like + required: false + style: form + explode: true + schema: + type: string + enum: + - json + - jsonp + - msgpack + - html + - name: channelId + in: path + description: "The [Channel's ID](https://www.ably.io/documentation/rest/channels)." + required: true + style: simple + explode: false + schema: + type: string + - name: clientId + in: query + description: Optional filter to restrict members present with that clientId + required: false + style: form + explode: true + schema: + type: string + - name: connectionId + in: query + description: Optional filter to restrict members present with that connectionId + required: false + style: form + explode: true + schema: + type: string + - name: limit + in: query + description: "The maximum number of records to return. A limit greater than\ + \ 1,000 is invalid." + required: false + style: form + explode: true + schema: + type: integer + default: 100 + responses: + "200": + description: OK + headers: + link: + $ref: "#/components/headers/Link" + x-ably-serverid: + $ref: "#/components/headers/ServerId" + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/PresenceMessage" + application/x-msgpack: + schema: + type: array + items: + $ref: "#/components/schemas/PresenceMessage" + text/html: + schema: + type: string + default: + description: Error + headers: + x-ably-errorcode: + $ref: "#/components/headers/ErrorCode" + x-ably-errormessage: + $ref: "#/components/headers/ErrorMessage" + x-ably-serverid: + $ref: "#/components/headers/ServerId" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + application/x-msgpack: + schema: + $ref: "#/components/schemas/Error" + text/html: + schema: + $ref: "#/components/schemas/Error" + /channels/{channelId}/presence/history: + get: + tags: + - History + summary: Get presence history of a channel + description: Get presence on a channel + operationId: getPresenceHistoryOfChannel + parameters: + - name: X-Ably-Version + in: header + description: The version of the API you wish to use. + required: false + style: simple + explode: false + schema: + type: string + x-ballerina-name: xAblyVersion + - name: format + in: query + description: The response format you would like + required: false + style: form + explode: true + schema: + type: string + enum: + - json + - jsonp + - msgpack + - html + - name: channelId + in: path + description: "The [Channel's ID](https://www.ably.io/documentation/rest/channels)." + required: true + style: simple + explode: false + schema: + type: string + - name: start + in: query + description: Beginning of time The start of the query interval as a time in + milliseconds since the epoch. A message qualifies as a member of the result + set if it was received at or after this time. + required: false + style: form + explode: true + schema: + type: string + - name: limit + in: query + description: "The maximum number of records to return. A limit greater than\ + \ 1,000 is invalid." + required: false + style: form + explode: true + schema: + type: integer + - name: end + in: query + description: The end of the query interval as a time in milliseconds since + the epoch. A message qualifies as a member of the result set if it was received + at or before this time. + required: false + style: form + explode: true + schema: + type: string + default: now + - name: direction + in: query + description: "The direction of this query. The direction determines the order\ + \ of the returned result array, but also determines which end of the query\ + \ interval is the start point for the search. For example, a forwards query\ + \ uses start as the start point, whereas a backwards query uses end as the\ + \ start point." + required: false + style: form + explode: true + schema: + type: string + default: backwards + enum: + - forwards + - backwards + responses: + "2XX": + description: OK + headers: + link: + $ref: "#/components/headers/Link" + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/PresenceMessage" + application/x-msgpack: + schema: + type: array + items: + $ref: "#/components/schemas/PresenceMessage" + text/html: + schema: + type: string + default: + description: Error + headers: + x-ably-errorcode: + $ref: "#/components/headers/ErrorCode" + x-ably-errormessage: + $ref: "#/components/headers/ErrorMessage" + x-ably-serverid: + $ref: "#/components/headers/ServerId" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + application/x-msgpack: + schema: + $ref: "#/components/schemas/Error" + text/html: + schema: + $ref: "#/components/schemas/Error" + /keys/{keyName}/requestToken: + post: + tags: + - Authentication + summary: Request an access token + description: "This is the means by which clients obtain access tokens to use\ + \ the service. You can see how to construct an Ably TokenRequest in the [Ably\ + \ TokenRequest spec](https://www.ably.io/documentation/rest-api/token-request-spec)\ + \ documentation, although we recommend you use an Ably SDK rather to create\ + \ a TokenRequest, as the construction of a TokenRequest is complex. The resulting\ + \ token response object contains the token properties as defined in Ably TokenRequest\ + \ spec. Authentication is not required if using a Signed TokenRequest." + operationId: requestAccessToken + parameters: + - name: X-Ably-Version + in: header + description: The version of the API you wish to use. + required: false + style: simple + explode: false + schema: + type: string + x-ballerina-name: xAblyVersion + - name: format + in: query + description: The response format you would like + required: false + style: form + explode: true + schema: + type: string + enum: + - json + - jsonp + - msgpack + - html + - name: keyName + in: path + description: "The [key name](https://www.ably.io/documentation/rest-api/token-request-spec#api-key-format)\ + \ comprises of the app ID and key ID of an API key." + required: true + style: simple + explode: false + schema: + type: string + requestBody: + description: Request Body + content: + application/json: + schema: + oneOf: + - $ref: "#/components/schemas/TokenRequest" + - $ref: "#/components/schemas/SignedTokenRequest" + example: + capability: + channel1: + - publish + - subscribe + wildcard:channels:*: + - publish + keyName: YourKey.Name + timestamp: "1559124196551" + responses: + "2XX": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/TokenDetails" + application/x-msgpack: + schema: + $ref: "#/components/schemas/TokenDetails" + default: + description: Error + headers: + x-ably-errorcode: + $ref: "#/components/headers/ErrorCode" + x-ably-errormessage: + $ref: "#/components/headers/ErrorMessage" + x-ably-serverid: + $ref: "#/components/headers/ServerId" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + application/x-msgpack: + schema: + $ref: "#/components/schemas/Error" + text/html: + schema: + $ref: "#/components/schemas/Error" + /push/channelSubscriptions: + get: + tags: + - Push + summary: List channel subscriptions + description: Get a list of push notification subscriptions to channels. + operationId: getPushSubscriptionsOnChannels + parameters: + - name: X-Ably-Version + in: header + description: The version of the API you wish to use. + required: false + style: simple + explode: false + schema: + type: string + x-ballerina-name: xAblyVersion + - name: format + in: query + description: The response format you would like + required: false + style: form + explode: true + schema: + type: string + enum: + - json + - jsonp + - msgpack + - html + - name: channel + in: query + description: Filter to restrict to subscriptions associated with that channel. + required: false + style: form + explode: true + schema: + type: string + - name: deviceId + in: query + description: Optional filter to restrict to devices associated with that deviceId. + Cannot be used with clientId. + required: false + style: form + explode: true + schema: + type: string + - name: clientId + in: query + description: Optional filter to restrict to devices associated with that clientId. + Cannot be used with deviceId. + required: false + style: form + explode: true + schema: + type: string + - name: limit + in: query + description: The maximum number of records to return. + required: false + style: form + explode: true + schema: + maximum: 1000 + type: integer + default: 100 + responses: + "2XX": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/DeviceDetails" + default: + description: Error + headers: + x-ably-errorcode: + $ref: "#/components/headers/ErrorCode" + x-ably-errormessage: + $ref: "#/components/headers/ErrorMessage" + x-ably-serverid: + $ref: "#/components/headers/ServerId" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + application/x-msgpack: + schema: + $ref: "#/components/schemas/Error" + text/html: + schema: + $ref: "#/components/schemas/Error" + post: + tags: + - Push + summary: Subscribe a device to a channel + description: Subscribe either a single device or all devices associated with + a client ID to receive push notifications from messages sent to a channel. + operationId: subscribePushDeviceToChannel + parameters: + - name: X-Ably-Version + in: header + description: The version of the API you wish to use. + required: false + style: simple + explode: false + schema: + type: string + x-ballerina-name: xAblyVersion + - name: format + in: query + description: The response format you would like + required: false + style: form + explode: true + schema: + type: string + enum: + - json + - jsonp + - msgpack + - html + requestBody: + description: Request Body + content: + application/json: + schema: + oneOf: + - type: object + properties: + channel: + type: string + description: Channel name. + deviceId: + type: string + description: "Must be set when clientId is empty, cannot be used\ + \ with clientId." + - type: object + properties: + clientId: + type: string + description: "Must be set when deviceId is empty, cannot be used\ + \ with deviceId." + channel: + type: string + description: Channel name. + example: + channel: my:channel + clientId: myClientId + application/x-msgpack: + schema: + oneOf: + - type: object + properties: + channel: + type: string + description: Channel name. + deviceId: + type: string + description: "Must be set when clientId is empty, cannot be used\ + \ with clientId." + - type: object + properties: + clientId: + type: string + description: "Must be set when deviceId is empty, cannot be used\ + \ with deviceId." + channel: + type: string + description: Channel name. + example: + channel: my:channel + clientId: myClientId + application/x-www-form-urlencoded: + schema: + oneOf: + - type: object + properties: + channel: + type: string + description: Channel name. + deviceId: + type: string + description: "Must be set when clientId is empty, cannot be used\ + \ with clientId." + - type: object + properties: + clientId: + type: string + description: "Must be set when deviceId is empty, cannot be used\ + \ with deviceId." + channel: + type: string + description: Channel name. + example: + channel: my:channel + clientId: myClientId + responses: + "2XX": + description: OK + default: + description: Error + headers: + x-ably-errorcode: + $ref: "#/components/headers/ErrorCode" + x-ably-errormessage: + $ref: "#/components/headers/ErrorMessage" + x-ably-serverid: + $ref: "#/components/headers/ServerId" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + application/x-msgpack: + schema: + $ref: "#/components/schemas/Error" + text/html: + schema: + $ref: "#/components/schemas/Error" + delete: + tags: + - Push + summary: Delete a registered device's update token + description: Delete a device details object. + operationId: deletePushDeviceDetails + parameters: + - name: X-Ably-Version + in: header + description: The version of the API you wish to use. + required: false + style: simple + explode: false + schema: + type: string + x-ballerina-name: xAblyVersion + - name: format + in: query + description: The response format you would like + required: false + style: form + explode: true + schema: + type: string + enum: + - json + - jsonp + - msgpack + - html + - name: channel + in: query + description: Filter to restrict to subscriptions associated with that channel. + required: false + style: form + explode: true + schema: + type: string + - name: deviceId + in: query + description: "Must be set when clientId is empty, cannot be used with clientId." + required: false + style: form + explode: true + schema: + type: string + - name: clientId + in: query + description: "Must be set when deviceId is empty, cannot be used with deviceId." + required: false + style: form + explode: true + schema: + type: string + responses: + "2XX": + description: OK + default: + description: Error + headers: + x-ably-errorcode: + $ref: "#/components/headers/ErrorCode" + x-ably-errormessage: + $ref: "#/components/headers/ErrorMessage" + x-ably-serverid: + $ref: "#/components/headers/ServerId" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + application/x-msgpack: + schema: + $ref: "#/components/schemas/Error" + text/html: + schema: + $ref: "#/components/schemas/Error" + /push/channels: + get: + tags: + - Push + summary: List all channels with at least one subscribed device + description: Returns a paginated response of channel names. + operationId: getChannelsWithPushSubscribers + parameters: + - name: X-Ably-Version + in: header + description: The version of the API you wish to use. + required: false + style: simple + explode: false + schema: + type: string + x-ballerina-name: xAblyVersion + - name: format + in: query + description: The response format you would like + required: false + style: form + explode: true + schema: + type: string + enum: + - json + - jsonp + - msgpack + - html + responses: + "2XX": + description: OK + content: + application/json: + schema: + type: array + items: + type: string + application/x-msgpack: + schema: + type: array + items: + type: string + text/html: + schema: + type: array + items: + type: string + default: + description: Error + headers: + x-ably-errorcode: + $ref: "#/components/headers/ErrorCode" + x-ably-errormessage: + $ref: "#/components/headers/ErrorMessage" + x-ably-serverid: + $ref: "#/components/headers/ServerId" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + application/x-msgpack: + schema: + $ref: "#/components/schemas/Error" + text/html: + schema: + $ref: "#/components/schemas/Error" + /push/deviceRegistrations: + get: + tags: + - Push + summary: List devices registered for receiving push notifications + description: List of device details of devices registed for push notifications. + operationId: getRegisteredPushDevices + parameters: + - name: X-Ably-Version + in: header + description: The version of the API you wish to use. + required: false + style: simple + explode: false + schema: + type: string + x-ballerina-name: xAblyVersion + - name: format + in: query + description: The response format you would like + required: false + style: form + explode: true + schema: + type: string + enum: + - json + - jsonp + - msgpack + - html + - name: deviceId + in: query + description: Optional filter to restrict to devices associated with that deviceId. + required: false + style: form + explode: true + schema: + type: string + - name: clientId + in: query + description: Optional filter to restrict to devices associated with that clientId. + required: false + style: form + explode: true + schema: + type: string + - name: limit + in: query + description: The maximum number of records to return. + required: false + style: form + explode: true + schema: + maximum: 1000 + type: integer + default: 100 + responses: + "2XX": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/DeviceDetails" + application/x-msgpack: + schema: + $ref: "#/components/schemas/DeviceDetails" + text/html: + schema: + $ref: "#/components/schemas/DeviceDetails" + default: + description: Error + headers: + x-ably-errorcode: + $ref: "#/components/headers/ErrorCode" + x-ably-errormessage: + $ref: "#/components/headers/ErrorMessage" + x-ably-serverid: + $ref: "#/components/headers/ServerId" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + application/x-msgpack: + schema: + $ref: "#/components/schemas/Error" + text/html: + schema: + $ref: "#/components/schemas/Error" + post: + tags: + - Push + summary: Register a device for receiving push notifications + description: "Register a device’s details, including the information necessary\ + \ to deliver push notifications to it. Requires \"push-admin\" capability." + operationId: registerPushDevice + parameters: + - name: X-Ably-Version + in: header + description: The version of the API you wish to use. + required: false + style: simple + explode: false + schema: + type: string + x-ballerina-name: xAblyVersion + - name: format + in: query + description: The response format you would like + required: false + style: form + explode: true + schema: + type: string + enum: + - json + - jsonp + - msgpack + - html + requestBody: + description: Device Details + content: + application/json: + schema: + $ref: "#/components/schemas/DeviceDetails" + application/x-msgpack: + schema: + $ref: "#/components/schemas/DeviceDetails" + responses: + "2XX": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/DeviceDetails" + application/x-msgpack: + schema: + $ref: "#/components/schemas/DeviceDetails" + text/html: + schema: + $ref: "#/components/schemas/DeviceDetails" + default: + description: Error + headers: + x-ably-errorcode: + $ref: "#/components/headers/ErrorCode" + x-ably-errormessage: + $ref: "#/components/headers/ErrorMessage" + x-ably-serverid: + $ref: "#/components/headers/ServerId" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + application/x-msgpack: + schema: + $ref: "#/components/schemas/Error" + text/html: + schema: + $ref: "#/components/schemas/Error" + delete: + tags: + - Push + summary: Unregister matching devices for push notifications + description: Unregisters devices. All their subscriptions for receiving push + notifications through channels will also be deleted. + operationId: unregisterAllPushDevices + parameters: + - name: X-Ably-Version + in: header + description: The version of the API you wish to use. + required: false + style: simple + explode: false + schema: + type: string + x-ballerina-name: xAblyVersion + - name: format + in: query + description: The response format you would like + required: false + style: form + explode: true + schema: + type: string + enum: + - json + - jsonp + - msgpack + - html + - name: deviceId + in: query + description: Optional filter to restrict to devices associated with that deviceId. + Cannot be used with clientId. + required: false + style: form + explode: true + schema: + type: string + - name: clientId + in: query + description: Optional filter to restrict to devices associated with that clientId. + Cannot be used with deviceId. + required: false + style: form + explode: true + schema: + type: string + responses: + "2XX": + description: OK + default: + description: Error + headers: + x-ably-errorcode: + $ref: "#/components/headers/ErrorCode" + x-ably-errormessage: + $ref: "#/components/headers/ErrorMessage" + x-ably-serverid: + $ref: "#/components/headers/ServerId" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + application/x-msgpack: + schema: + $ref: "#/components/schemas/Error" + text/html: + schema: + $ref: "#/components/schemas/Error" + /push/deviceRegistrations/{deviceId}: + get: + tags: + - Push + summary: Get a device registration + description: Get the full details of a device. + operationId: getPushDeviceDetails + parameters: + - name: X-Ably-Version + in: header + description: The version of the API you wish to use. + required: false + style: simple + explode: false + schema: + type: string + x-ballerina-name: xAblyVersion + - name: format + in: query + description: The response format you would like + required: false + style: form + explode: true + schema: + type: string + enum: + - json + - jsonp + - msgpack + - html + - name: deviceId + in: path + description: Device's ID. + required: true + style: simple + explode: false + schema: + type: string + responses: + "2XX": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/DeviceDetails" + application/x-msgpack: + schema: + $ref: "#/components/schemas/DeviceDetails" + text/html: + schema: + $ref: "#/components/schemas/DeviceDetails" + default: + description: Error + headers: + x-ably-errorcode: + $ref: "#/components/headers/ErrorCode" + x-ably-errormessage: + $ref: "#/components/headers/ErrorMessage" + x-ably-serverid: + $ref: "#/components/headers/ServerId" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + application/x-msgpack: + schema: + $ref: "#/components/schemas/Error" + text/html: + schema: + $ref: "#/components/schemas/Error" + put: + tags: + - Push + summary: Update a device registration + description: "Device registrations can be upserted (the existing registration\ + \ is replaced entirely) with a PUT operation. Only clientId, metadata and\ + \ push.recipient are mutable." + operationId: putPushDeviceDetails + parameters: + - name: X-Ably-Version + in: header + description: The version of the API you wish to use. + required: false + style: simple + explode: false + schema: + type: string + x-ballerina-name: xAblyVersion + - name: format + in: query + description: The response format you would like + required: false + style: form + explode: true + schema: + type: string + enum: + - json + - jsonp + - msgpack + - html + - name: deviceId + in: path + description: Device's ID. + required: true + style: simple + explode: false + schema: + type: string + requestBody: + description: Device Details + content: + application/json: + schema: + $ref: "#/components/schemas/DeviceDetails" + application/x-msgpack: + schema: + $ref: "#/components/schemas/DeviceDetails" + application/x-www-form-urlencoded: + schema: + $ref: "#/components/schemas/DeviceDetails" + responses: + "2XX": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/DeviceDetails" + application/x-msgpack: + schema: + $ref: "#/components/schemas/DeviceDetails" + text/html: + schema: + $ref: "#/components/schemas/DeviceDetails" + default: + description: Error + headers: + x-ably-errorcode: + $ref: "#/components/headers/ErrorCode" + x-ably-errormessage: + $ref: "#/components/headers/ErrorMessage" + x-ably-serverid: + $ref: "#/components/headers/ServerId" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + application/x-msgpack: + schema: + $ref: "#/components/schemas/Error" + text/html: + schema: + $ref: "#/components/schemas/Error" + delete: + tags: + - Push + summary: Unregister a single device for push notifications + description: Unregisters a single device by its device ID. All its subscriptions + for receiving push notifications through channels will also be deleted. + operationId: unregisterPushDevice + parameters: + - name: X-Ably-Version + in: header + description: The version of the API you wish to use. + required: false + style: simple + explode: false + schema: + type: string + x-ballerina-name: xAblyVersion + - name: format + in: query + description: The response format you would like + required: false + style: form + explode: true + schema: + type: string + enum: + - json + - jsonp + - msgpack + - html + - name: deviceId + in: path + description: Device's ID. + required: true + style: simple + explode: false + schema: + type: string + responses: + "2XX": + description: OK + default: + description: Error + headers: + x-ably-errorcode: + $ref: "#/components/headers/ErrorCode" + x-ably-errormessage: + $ref: "#/components/headers/ErrorMessage" + x-ably-serverid: + $ref: "#/components/headers/ServerId" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + application/x-msgpack: + schema: + $ref: "#/components/schemas/Error" + text/html: + schema: + $ref: "#/components/schemas/Error" + patch: + tags: + - Push + summary: Update a device registration + description: "Specific attributes of an existing registration can be updated.\ + \ Only clientId, metadata and push.recipient are mutable." + operationId: patchPushDeviceDetails + parameters: + - name: X-Ably-Version + in: header + description: The version of the API you wish to use. + required: false + style: simple + explode: false + schema: + type: string + x-ballerina-name: xAblyVersion + - name: format + in: query + description: The response format you would like + required: false + style: form + explode: true + schema: + type: string + enum: + - json + - jsonp + - msgpack + - html + - name: deviceId + in: path + description: Device's ID. + required: true + style: simple + explode: false + schema: + type: string + requestBody: + description: Device Details + content: + application/json: + schema: + $ref: "#/components/schemas/DeviceDetails" + application/x-msgpack: + schema: + $ref: "#/components/schemas/DeviceDetails" + application/x-www-form-urlencoded: + schema: + $ref: "#/components/schemas/DeviceDetails" + responses: + "2XX": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/DeviceDetails" + application/x-msgpack: + schema: + $ref: "#/components/schemas/DeviceDetails" + text/html: + schema: + $ref: "#/components/schemas/DeviceDetails" + default: + description: Error + headers: + x-ably-errorcode: + $ref: "#/components/headers/ErrorCode" + x-ably-errormessage: + $ref: "#/components/headers/ErrorMessage" + x-ably-serverid: + $ref: "#/components/headers/ServerId" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + application/x-msgpack: + schema: + $ref: "#/components/schemas/Error" + text/html: + schema: + $ref: "#/components/schemas/Error" + /push/deviceRegistrations/{deviceId}/resetUpdateToken: + get: + tags: + - Push + summary: Reset a registered device's update token + description: Gets an updated device details object. + operationId: updatePushDeviceDetails + parameters: + - name: X-Ably-Version + in: header + description: The version of the API you wish to use. + required: false + style: simple + explode: false + schema: + type: string + x-ballerina-name: xAblyVersion + - name: format + in: query + description: The response format you would like + required: false + style: form + explode: true + schema: + type: string + enum: + - json + - jsonp + - msgpack + - html + - name: deviceId + in: path + description: Device's ID. + required: true + style: simple + explode: false + schema: + type: string + responses: + "2XX": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/DeviceDetails" + application/x-msgpack: + schema: + $ref: "#/components/schemas/DeviceDetails" + text/html: + schema: + $ref: "#/components/schemas/DeviceDetails" + default: + description: Error + headers: + x-ably-errorcode: + $ref: "#/components/headers/ErrorCode" + x-ably-errormessage: + $ref: "#/components/headers/ErrorMessage" + x-ably-serverid: + $ref: "#/components/headers/ServerId" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + application/x-msgpack: + schema: + $ref: "#/components/schemas/Error" + text/html: + schema: + $ref: "#/components/schemas/Error" + /push/publish: + post: + tags: + - Push + summary: Publish a push notification to device(s) + description: A convenience endpoint to deliver a push notification payload to + a single device or set of devices identified by their client identifier. + operationId: publishPushNotificationToDevices + parameters: + - name: X-Ably-Version + in: header + description: The version of the API you wish to use. + required: false + style: simple + explode: false + schema: + type: string + x-ballerina-name: xAblyVersion + - name: format + in: query + description: The response format you would like + required: false + style: form + explode: true + schema: + type: string + enum: + - json + - jsonp + - msgpack + - html + requestBody: + description: Request Body + content: + application/json: + schema: + required: + - recipient + type: object + properties: + recipient: + $ref: "#/components/schemas/Recipient" + push: + $ref: "#/components/schemas/Push" + application/x-msgpack: + schema: + required: + - recipient + type: object + properties: + recipient: + $ref: "#/components/schemas/Recipient" + push: + $ref: "#/components/schemas/Push" + application/x-www-form-urlencoded: + schema: + required: + - recipient + type: object + properties: + recipient: + $ref: "#/components/schemas/Recipient" + push: + $ref: "#/components/schemas/Push" + responses: + "2XX": + description: OK + default: + description: Error + headers: + x-ably-errorcode: + $ref: "#/components/headers/ErrorCode" + x-ably-errormessage: + $ref: "#/components/headers/ErrorMessage" + x-ably-serverid: + $ref: "#/components/headers/ServerId" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + application/x-msgpack: + schema: + $ref: "#/components/schemas/Error" + text/html: + schema: + $ref: "#/components/schemas/Error" + /stats: + get: + tags: + - Stats + summary: Retrieve usage statistics for an application + description: "The Ably system can be queried to obtain usage statistics for\ + \ a given application, and results are provided aggregated across all channels\ + \ in use in the application in the specified period. Stats may be used to\ + \ track usage against account quotas." + operationId: getStats + parameters: + - name: X-Ably-Version + in: header + description: The version of the API you wish to use. + required: false + style: simple + explode: false + schema: + type: string + x-ballerina-name: xAblyVersion + - name: format + in: query + description: The response format you would like + required: false + style: form + explode: true + schema: + type: string + enum: + - json + - jsonp + - msgpack + - html + - name: start + in: query + description: Beginning of time The start of the query interval as a time in + milliseconds since the epoch. A message qualifies as a member of the result + set if it was received at or after this time. + required: false + style: form + explode: true + schema: + type: string + - name: limit + in: query + description: "The maximum number of records to return. A limit greater than\ + \ 1,000 is invalid." + required: false + style: form + explode: true + schema: + type: integer + - name: end + in: query + description: The end of the query interval as a time in milliseconds since + the epoch. A message qualifies as a member of the result set if it was received + at or before this time. + required: false + style: form + explode: true + schema: + type: string + default: now + - name: direction + in: query + description: "The direction of this query. The direction determines the order\ + \ of the returned result array, but also determines which end of the query\ + \ interval is the start point for the search. For example, a forwards query\ + \ uses start as the start point, whereas a backwards query uses end as the\ + \ start point." + required: false + style: form + explode: true + schema: + type: string + default: backwards + enum: + - forwards + - backwards + - name: unit + in: query + description: Specifies the unit of aggregation in the returned results. + required: false + style: form + explode: true + schema: + type: string + default: minute + enum: + - minute + - hour + - day + - month + responses: + "2XX": + description: OK + content: + application/json: + schema: + type: object + default: + description: Error + headers: + x-ably-errorcode: + $ref: "#/components/headers/ErrorCode" + x-ably-errormessage: + $ref: "#/components/headers/ErrorMessage" + x-ably-serverid: + $ref: "#/components/headers/ServerId" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + application/x-msgpack: + schema: + $ref: "#/components/schemas/Error" + text/html: + schema: + $ref: "#/components/schemas/Error" + /time: + get: + tags: + - Stats + summary: Get the service time + description: This returns the service time in milliseconds since the epoch. + operationId: getTime + parameters: + - name: X-Ably-Version + in: header + description: The version of the API you wish to use. + required: false + style: simple + explode: false + schema: + type: string + x-ballerina-name: xAblyVersion + - name: format + in: query + description: The response format you would like + required: false + style: form + explode: true + schema: + type: string + enum: + - json + - jsonp + - msgpack + - html + responses: + "2XX": + description: OK + content: + application/json: + schema: + type: array + items: + type: integer + application/x-msgpack: + schema: + type: array + items: + type: integer + text/html: + schema: + type: string + default: + description: Error + headers: + x-ably-errorcode: + $ref: "#/components/headers/ErrorCode" + x-ably-errormessage: + $ref: "#/components/headers/ErrorMessage" + x-ably-serverid: + $ref: "#/components/headers/ServerId" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + application/x-msgpack: + schema: + $ref: "#/components/schemas/Error" + text/html: + schema: + $ref: "#/components/schemas/Error" + security: [] +components: + schemas: + DeviceDetails: + type: object + properties: + pushState: + type: string + description: the current state of the push device. + readOnly: true + enum: + - Active + - Failing + - Failed + deviceSecret: + type: string + description: Secret value for the device. + metadata: + type: object + description: Optional metadata object for this device. The metadata for + a device may only be set by clients with push-admin privileges and will + be used more extensively in the future with smart notifications. + clientId: + type: string + description: Optional trusted client identifier for the device. + formFactor: + type: string + description: Form factor of the push device. + enum: + - phone + - tablet + - desktop + - tv + - watch + - car + - embedded + pushRecipient: + $ref: "#/components/schemas/Recipient" + id: + type: string + description: Unique identifier for the device generated by the device itself. + platform: + type: string + description: Platform of the push device. + enum: + - ios + - android + PresenceMessage: + type: object + properties: + clientId: + type: string + description: The client ID of the publisher of this presence update. + data: + type: string + description: "The presence update payload, if provided." + action: + type: string + description: The event signified by a PresenceMessage. + readOnly: true + enum: + - ABSENT + - PRESENT + - ENTER + - LEAVE + - UPDATE + connectionId: + type: string + description: The connection ID of the publisher of this presence update. + extras: + $ref: "#/components/schemas/Extras" + id: + type: string + description: Unique ID assigned by Ably to this presence update. + readOnly: true + encoding: + type: string + description: "This will typically be empty as all presence updates received\ + \ from Ably are automatically decoded client-side using this value. However,\ + \ if the message encoding cannot be processed, this attribute will contain\ + \ the remaining transformations not applied to the data payload." + timestamp: + type: integer + description: "Timestamp when the presence update was received by Ably, as\ + \ milliseconds since the epoch." + format: int64 + readOnly: true + Message: + type: object + properties: + clientId: + type: string + description: "The [client ID](https://www.ably.io/documentation/core-features/authentication#identified-clients)\ + \ of the publisher of this message." + data: + type: string + description: "The string encoded payload, with the encoding specified below." + name: + type: string + description: "The event name, if provided." + connectionId: + type: string + description: The connection ID of the publisher of this message. + extras: + $ref: "#/components/schemas/Extras" + id: + type: string + description: "A Unique ID that can be specified by the publisher for [idempotent\ + \ publishing](https://www.ably.io/documentation/rest/messages#idempotent)." + readOnly: true + encoding: + type: string + description: "This will typically be empty as all messages received from\ + \ Ably are automatically decoded client-side using this value. However,\ + \ if the message encoding cannot be processed, this attribute will contain\ + \ the remaining transformations not applied to the data payload." + timestamp: + type: integer + description: "Timestamp when the message was received by the Ably, as milliseconds\ + \ since the epoch." + format: int64 + readOnly: true + description: Message object. + ChannelDetails: + required: + - channelId + type: object + properties: + isGlobalMaster: + type: boolean + description: "In events relating to the activity of a channel in a specific\ + \ region, this optionally identifies whether or not that region is responsible\ + \ for global coordination of the channel." + region: + type: string + description: "In events relating to the activity of a channel in a specific\ + \ region, this optionally identifies the region." + channelId: + type: string + description: "The required name of the channel including any qualifier,\ + \ if any." + status: + $ref: "#/components/schemas/ChannelStatus" + Error: + type: object + properties: + code: + type: integer + description: Error code. + href: + type: string + description: Link to help with error. + message: + type: string + description: Message explaining the error's cause. + serverId: + type: string + description: Server ID with which error was encountered. + statusCode: + type: integer + description: Status error code. + description: Returned error from failed REST. + Recipient: + type: object + properties: + registrationToken: + type: string + description: "when using GCM or FCM, specifies the required registration\ + \ token." + clientId: + type: string + description: Client ID of recipient + writeOnly: true + transportType: + type: string + description: Defines which push platform is being used. + enum: + - apns + - fcm + - gcm + deviceId: + type: string + description: Client ID of recipient + writeOnly: true + deviceToken: + type: string + description: "when using APNs, specifies the required device token." + description: Push recipient details for a device. + ChannelStatus: + required: + - isActive + type: object + properties: + occupancy: + $ref: "#/components/schemas/Occupancy" + isActive: + type: boolean + description: "A required boolean value indicating whether the channel that\ + \ is the subject of the event is active. For events indicating regional\ + \ activity of a channel this indicates activity in that region, not global\ + \ activity." + description: A ChannelStatus instance. + Extras: + type: object + properties: + push: + $ref: "#/components/schemas/Push" + description: "Extras object. Currently only allows for [push](https://www.ably.io/documentation/general/push/publish#channel-broadcast-example)\ + \ extra." + Notification: + type: object + properties: + collapseKey: + type: string + description: "Platform-specific, used to group notifications together." + sound: + type: string + description: Platform-specific sound for the notification. + icon: + type: string + description: Platform-specific icon for the notification. + body: + type: string + description: Text below title on the expanded notification. + title: + type: string + description: Title to display at the notification. + description: Notification + TokenDetails: + type: object + properties: + capability: + type: string + description: Regular expression representation of the capabilities of the + token. + expires: + type: integer + description: Timestamp of token expiration. + keyName: + type: string + description: Name of the key used to create the token + issued: + type: integer + description: Timestamp of token creation. + token: + type: string + description: The Ably Token. + Occupancy: + type: object + properties: + presenceMembers: + type: integer + description: The number of members currently entered into the presence channel. + presenceSubscribers: + type: integer + description: The number of connections that are authorised to subscribe + to presence messages. + subscribers: + type: integer + description: The number of connections attached that are authorised to subscribe + to messages. + publishers: + type: integer + description: The number of connections attached to the channel that are + authorised to publish. + presenceConnections: + type: integer + description: The number of connections that are authorised to enter members + into the presence channel. + description: "An Occupancy instance indicating the occupancy of a channel. For\ + \ events indicating regional activity of a channel this indicates activity\ + \ in that region, not global activity." + TokenRequest: + required: + - capability + - keyName + - nonce + - timestamp + type: object + properties: + capability: + type: object + description: "The [capabilities](https://www.ably.io/documentation/core-features/authentication#capabilities-explained)\ + \ (i.e. a set of channel names/namespaces and, for each, a set of operations)\ + \ which should be a subset of the set of capabilities associated with\ + \ the key specified in keyName." + example: + channel1: + - publish + - subscribe + clientId: + type: string + description: "The [client ID](https://www.ably.io/documentation/core-features/authentication#identified-clients)\ + \ to be assosciated with the token. Can be set to * to allow for any client\ + \ ID to be used." + keyName: + type: string + description: Name of the key used for the TokenRequest. The keyName comprises + of the app ID and key ID on an API Key. + example: xVLyHw.LMJZxw + nonce: + type: string + description: "An unquoted, un-escaped random string of at least 16 characters.\ + \ Used to ensure the Ably TokenRequest cannot be reused." + timestamp: + type: integer + description: Time of creation of the Ably TokenRequest. + Push: + type: object + properties: + fcm: + type: object + properties: + notification: + $ref: "#/components/schemas/Notification" + description: "Extends and overrides generic values when delivering via GCM/FCM.\ + \ [See examples](https://www.ably.io/documentation/general/push/publish#payload-structure)" + notification: + $ref: "#/components/schemas/Notification" + data: + type: string + description: "Arbitrary [key-value string-to-string payload](https://www.ably.io/documentation/general/push/publish#channel-broadcast-example)." + web: + type: object + properties: + notification: + $ref: "#/components/schemas/Notification" + description: "Extends and overrides generic values when delivering via web.\ + \ [See examples](https://www.ably.io/documentation/general/push/publish#payload-structure)" + apns: + type: object + properties: + notification: + $ref: "#/components/schemas/Notification" + description: "Extends and overrides generic values when delivering via APNs.\ + \ [See examples](https://www.ably.io/documentation/general/push/publish#payload-structure)" + description: Push + SignedTokenRequest: + allOf: + - $ref: "#/components/schemas/TokenRequest" + - required: + - mac + type: object + properties: + mac: + type: string + description: "A signature, generated as an HMAC of each of the above components,\ + \ using the key secret value." + responses: + Error: + description: Error + headers: + x-ably-errorcode: + $ref: "#/components/headers/ErrorCode" + x-ably-errormessage: + $ref: "#/components/headers/ErrorMessage" + x-ably-serverid: + $ref: "#/components/headers/ServerId" + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + application/x-msgpack: + schema: + $ref: "#/components/schemas/Error" + text/html: + schema: + $ref: "#/components/schemas/Error" + parameters: + channelId: + name: channel_id + in: path + description: "The [Channel's ID](https://www.ably.io/documentation/rest/channels)." + required: true + style: simple + explode: false + schema: + type: string + deviceId: + name: device_id + in: path + description: Device's ID. + required: true + style: simple + explode: false + schema: + type: string + filterDirection: + name: direction + in: query + description: "The direction of this query. The direction determines the order\ + \ of the returned result array, but also determines which end of the query\ + \ interval is the start point for the search. For example, a forwards query\ + \ uses start as the start point, whereas a backwards query uses end as the\ + \ start point." + required: false + style: form + explode: true + schema: + type: string + default: backwards + enum: + - forwards + - backwards + filterEnd: + name: end + in: query + description: The end of the query interval as a time in milliseconds since the + epoch. A message qualifies as a member of the result set if it was received + at or before this time. + required: false + style: form + explode: true + schema: + type: string + default: now + filterLimit: + name: limit + in: query + description: "The maximum number of records to return. A limit greater than\ + \ 1,000 is invalid." + required: false + style: form + explode: true + schema: + type: integer + filterStart: + name: start + in: query + description: Beginning of time The start of the query interval as a time in + milliseconds since the epoch. A message qualifies as a member of the result + set if it was received at or after this time. + required: false + style: form + explode: true + schema: + type: string + key_name: + name: keyName + in: path + description: "The [key name](https://www.ably.io/documentation/rest-api/token-request-spec#api-key-format)\ + \ comprises of the app ID and key ID of an API key." + required: true + style: simple + explode: false + schema: + type: string + responseFormat: + name: format + in: query + description: The response format you would like + required: false + style: form + explode: true + schema: + type: string + enum: + - json + - jsonp + - msgpack + - html + versionHeader: + name: X-Ably-Version + in: header + description: The version of the API you wish to use. + required: false + style: simple + explode: false + schema: + type: string + headers: + ErrorCode: + description: The error code. + style: simple + explode: false + schema: + type: integer + ErrorMessage: + description: The error message. + style: simple + explode: false + schema: + type: string + Link: + description: "Links to related resources, in the format defined by [RFC 5988](https://tools.ietf.org/html/rfc5988#section-5).\ + \ This will potentially include a link with relation type `next`, `first`,\ + \ and `current`, where appropiate." + required: true + style: simple + explode: false + schema: + pattern: "(<(.*)?>; rel=\\\"(first|current|last)?\\\",)*(<(.*)?>; rel=\\\"\ + (first|current|last)?\\\")+" + type: string + ServerId: + description: The ID for the server communicated with. + required: true + style: simple + explode: false + schema: + type: string + securitySchemes: + basicAuth: + type: http + description: "Basic Authentication using an [API key](https://www.ably.io/documentation/core-features/authentication#basic-authentication)." + scheme: basic + bearerAuth: + type: http + description: "Token Authentication using an [Ably Token](https://www.ably.io/documentation/core-features/authentication#basic-authentication),\ + \ or optionally an [Ably JWT](https://www.ably.io/documentation/core-features/authentication#ably-jwt-process)." + scheme: bearer From 600497908c96182bfca6be801c56e95fd5510b41 Mon Sep 17 00:00:00 2001 From: TharmiganK Date: Fri, 13 Dec 2024 12:32:52 +0530 Subject: [PATCH 3/4] Fix typo in the output message --- .../main/java/io/ballerina/openapi/cmd/SubCmdBase.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openapi-cli/src/main/java/io/ballerina/openapi/cmd/SubCmdBase.java b/openapi-cli/src/main/java/io/ballerina/openapi/cmd/SubCmdBase.java index 391737362..075283f19 100644 --- a/openapi-cli/src/main/java/io/ballerina/openapi/cmd/SubCmdBase.java +++ b/openapi-cli/src/main/java/io/ballerina/openapi/cmd/SubCmdBase.java @@ -77,7 +77,7 @@ public String getName() { private static final String COMMAND_IDENTIFIER = "openapi-%s"; private static final String COMMA = ","; - private static final String INFO_OUTPUT_WRITTEN_MSG = "INFO: %sed OpenAPI definition file was successfully" + + private static final String INFO_OUTPUT_WRITTEN_MSG = "INFO: %s OpenAPI definition file was successfully" + " written to: %s%n"; private static final String WARNING_INVALID_OUTPUT_FORMAT = "WARNING: invalid output format. The output format" + " should be either \"json\" or \"yaml\".Defaulting to format of the input file"; @@ -93,7 +93,7 @@ public String getName() { "parsing the OpenAPI definition file"; protected static final String FOUND_PARSER_DIAGNOSTICS = "found the following parser diagnostic messages:"; private static final String ERROR_OCCURRED_WHILE_WRITING_THE_OUTPUT_OPENAPI_FILE = "ERROR: error occurred while " + - "writing the %sed OpenAPI definition file%n"; + "writing the %s OpenAPI definition file%n"; private static final String WARNING_SWAGGER_V2_FOUND = "WARNING: Swagger version 2.0 found in the OpenAPI " + "definition. The generated OpenAPI definition will be in OpenAPI version 3.0.x"; @@ -292,9 +292,9 @@ private void writeGeneratedOpenAPIFile(OpenAPI openAPI) { try { CodegenUtils.writeFile(targetPath.resolve(outputFileNameWithExt), outputFileNameWithExt.endsWith(JSON_EXTENSION) ? Json.pretty(openAPI) : Yaml.pretty(openAPI)); - infoStream.printf(INFO_OUTPUT_WRITTEN_MSG, cmdType.getName(), targetPath.resolve(outputFileNameWithExt)); + infoStream.printf(INFO_OUTPUT_WRITTEN_MSG, infoMsgPrefix, targetPath.resolve(outputFileNameWithExt)); } catch (IOException exception) { - errorStream.printf(ERROR_OCCURRED_WHILE_WRITING_THE_OUTPUT_OPENAPI_FILE, cmdType.getName()); + errorStream.printf(ERROR_OCCURRED_WHILE_WRITING_THE_OUTPUT_OPENAPI_FILE, infoMsgPrefix); exitError(); } } From da0d6fbd626b130fbc72c90c47828bed351a5e1d Mon Sep 17 00:00:00 2001 From: TharmiganK Date: Fri, 13 Dec 2024 12:36:59 +0530 Subject: [PATCH 4/4] Fix check style issue --- .../src/test/java/io/ballerina/openapi/cmd/OpenAPICmdTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openapi-cli/src/test/java/io/ballerina/openapi/cmd/OpenAPICmdTest.java b/openapi-cli/src/test/java/io/ballerina/openapi/cmd/OpenAPICmdTest.java index 5278b47f7..1d0e19227 100644 --- a/openapi-cli/src/test/java/io/ballerina/openapi/cmd/OpenAPICmdTest.java +++ b/openapi-cli/src/test/java/io/ballerina/openapi/cmd/OpenAPICmdTest.java @@ -1130,7 +1130,8 @@ public void testSanitizeCmdWithComposedSchema() throws IOException { @Test(description = "Test openapi sanitize sub command with unresolved parameter schema") public void testSanitizeCmdWithUnresolvedParameterSchema() throws IOException { - Path expectedFilePath = resourceDir.resolve(Paths.get("cmd/sanitize/sanitized_openapi_unresolved_expected.yaml")); + Path expectedFilePath = resourceDir.resolve( + Paths.get("cmd/sanitize/sanitized_openapi_unresolved_expected.yaml")); String[] args = {"-i", resourceDir + "/cmd/sanitize/openapi_unresolved.yaml", "-o", tmpDir.toString()}; Sanitize sanitize = new Sanitize(); new CommandLine(sanitize).parseArgs(args);