Skip to content

Commit

Permalink
feat(openapi): add migration to delete servers
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Aug 11, 2023
1 parent a879b98 commit 46681d0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
10 changes: 10 additions & 0 deletions openapi/migrations/2023-08-11-delete-servers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import spec from '../spec.json';
import { traverse, writeSpec } from '../../utils';

traverse(spec, '', null, (value, key, parent) => {
if (key === 'servers') {
delete parent.servers;
}
});

writeSpec(spec);
5 changes: 0 additions & 5 deletions openapi/spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
"description": "# Braze API overview\n\nBraze provides a high-performance REST API to allow you to track users, send messages, export data, and more. This reference article covers what a REST API is, the terminology, a brief overview of API keys, and API limits.\n\nA REST API is a way to programmatically transfer information over the web using a predefined schema. Braze has created many different endpoints which perform various actions and/or return various data.\n\nBraze manages a number of different instances for our dashboard and REST Endpoints. When your account is provisioned you will log in to one of the following URLs. Use the correct REST endpoint based on which instance you are provisioned to. If you are unsure, open a [support ticket](https://www.braze.com/docs/braze_support/) or use the following table to match the URL of the dashboard you use to the correct REST Endpoint.\n\n> Customers using Braze’s EU database should use the `https://rest.fra-01.braze.eu/` endpoint. This endpoint will be used when configuring the Braze [iOS](https://www.braze.com/docs/developer_guide/platform_integration_guides/ios/initial_sdk_setup/completing_integration/#compile-time-endpoint-configuration-recommended), [Android](https://www.braze.com/docs/developer_guide/platform_integration_guides/android/initial_sdk_setup/android_sdk_integration/#step-2-configure-the-braze-sdk-in-brazexml), and [Web](https://www.braze.com/docs/developer_guide/platform_integration_guides/web/initial_sdk_setup/#step-2-initialize-braze) SDKs.\n\n## Braze Instances\n\n| Instance | Dashboard URL | REST Endpoint |\n| --- | --- | --- |\n| US-01 | `https://dashboard.braze.com` or <br>`https://dashboard-01.braze.com` | `https://rest.iad-01.braze.com` |\n| US-02 | `https://dashboard-02.braze.com` | `https://rest.iad-02.braze.com` |\n| US-03 | `https://dashboard-03.braze.com` | `https://rest.iad-03.braze.com` |\n| US-04 | `https://dashboard-04.braze.com` | `https://rest.iad-04.braze.com` |\n| US-05 | `https://dashboard-05.braze.com` | `https://rest.iad-05.braze.com` |\n| US-06 | `https://dashboard-06.braze.com` | `https://rest.iad-06.braze.com` |\n| US-08 | `https://dashboard-08.braze.com` | `https://rest.iad-08.braze.com` |\n| EU-01 | `https://dashboard-01.braze.eu` | `https://rest.fra-01.braze.eu` |\n| EU-02 | `https://dashboard-02.braze.eu` | `https://rest.fra-02.braze.eu` |\n\n# Using Braze's Postman collection\n\nIf you have a Postman account (you can download macOS, Windows, and Linux versions from the [Postman website](https://www.getpostman.com/) ), you can open our Postman documentation in your own Postman app by clicking the orange **Run in Postman** button. You can then [create an environment](https://www.braze.com/docs/api/postman_collection/#setting-up-your-postman-environment), or use our Braze REST API environment as a template, and edit the available `POST` and `GET` requests to suit your own needs.\n\n## Setting up your Postman environment\n\nThe Braze Postman Collection uses a templating variable, `https://rest.example.braze.com`, to substitute the REST API URL of your Braze instance into the pre-built requests, and the `{{api_key}}` variable for your API Key. Rather than having to manually edit all requests in the Collection, you can set up this variable in your Postman environment. You can either select our templated environment (Braze REST API Environment Template) from the dropdown and replace the variable values with your own, or you can set up your own environment.\n\nTo set up your own environment, perform the following steps:\n\n1. From the **Workspaces** tab, select **Environments**.\n2. Click the **+** plus button to create a new environment.\n3. Give this environment a name (e.g., “Braze API Requests”) and add keys for `instance_url` and `api_key` with values corresponding to your [Braze instance](https://www.braze.com/docs/developer_guide/rest_api/basics/#endpoints) and [Braze REST API Key](https://www.braze.com/docs/api/api_key/).\n4. Click **Save**.\n \n\n## Using the pre-built requests from the collection\n\nOnce you have configured your environment. You can use any of the pre-built requests in the collection as a template for building new API requests. To start using one of the pre-built requests, click on it within the **Collections** menu of Postman. This will open the request as a new tab in the main window of the Postman app.\n\nIn general, there are two types of requests that Braze’s API endpoints accept - `GET` and `POST`. Depending on which `HTTP` method the endpoint uses, you’ll need to edit the pre-built request differently.\n\n### Edit a POST request\n\nWhen editing a `POST` request, open the request and navigate to the **Body** section in the request editor. For readability, select the **raw** radio button to format the `JSON` request body.\n\n### Edit a GET request\n\nWhen editing a `GET` request, edit the parameters passed in the request URL. To do so, select the **Params** tab and edit the key-value pairs in the fields that appear.\n\n## Send your request\n\nOnce your API request is ready, click **Send**. The request sends and the response data populates in a section underneath the request editor. From here, you can view the raw data returned from Braze’s API, see the HTTP response code, see how long the request took to process, and view header information.\n\nThe following documentation can be found on the Braze documentation site:\n\n* [Object & filter specifications](https://www.braze.com/docs/api/objects_filters/)\n* [API key overview](https://www.braze.com/docs/api/api_key/)\n* [API identifier types](https://www.braze.com/docs/api/identifier_types/)\n* [Errors & responses](https://www.braze.com/docs/api/errors/)\n* [Parameters](https://www.braze.com/docs/api/parameters)\n* [Data retention](https://www.braze.com/docs/api/data_retention/)\n* [API network connectivity issues](https://www.braze.com/docs/api/network_connectivity_issues)\n* [Rate limits](https://www.braze.com/docs/api/api_limits/)\n* [API campaigns](https://www.braze.com/docs/api/api_campaigns/)",
"version": "1.0.0"
},
"servers": [
{ "url": "https://https" },
{ "url": "https://rest.iad-01.braze.com" },
{ "url": "https://sondheim.appboy.com" }
],
"components": {
"securitySchemes": { "noauthAuth": { "type": "http", "scheme": "noauth" } }
},
Expand Down
12 changes: 6 additions & 6 deletions utils/traverse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ export function traverse(
replacer: Replacer,
): void {
if (Array.isArray(children)) {
return children.forEach((value, index) =>
traverse(value, index, children, replacer),
);
return children.forEach((value, key) => {
replacer(value, key, children);
traverse(value, key, children, replacer);
});
}

if (children instanceof Object) {
return Object.keys(children).forEach((key) => {
const value = (children as Record<Key, Children>)[key];
replacer(value, key, children);
traverse(value, key, children, replacer);
});
}

if (typeof replacer === 'function') {
replacer(children, key, parent);
}
replacer(children, key, parent);
}

0 comments on commit 46681d0

Please sign in to comment.