Nav

How to Sync an API

When you update a RAML file from Anypoint Studio, the API Sync view allows you to synchronize those changes to your API version hosted in Anypoint Platform.

Prerequisites

To illustrate this quickstart, we are assuming you completed the t-shirt API in How to Implement and Test an API.

In order for API Sync to work, you need to edit an API in Studio that was imported from the Anypoint Platform.

Edit Your RAML File using The RAML Editor

Navigate to your t-shirt.raml file in your Package Explorer, double-click in it to open the file in your RAML Editor.

Locate your /orders:` resource definition, and right after the defined schema for the post: resource:


         
      
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
schema: |
  {
    "type": "object",
    "$schema": "http://json-schema.org/draft-03/schema",
    "id": "http://jsonschema.net",
    "required": true,
    "properties": {
      "address1": {
          "type": "string",
          "id": "http://jsonschema.net/address1",
          "required": true
      },
      "address2": {
          "type": "string",
          "id": "http://jsonschema.net/address2",
          "required": true
      },
      "city": {
          "type": "string",
          "id": "http://jsonschema.net/city",
          "required": true
      },
      "country": {
          "type": "string",
          "id": "http://jsonschema.net/country",
          "required": true
      },
      "email": {
          "type": "string",
          "format": "email",
          "id": "http://jsonschema.net/email",
          "required": true
      },
      "name": {
          "type": "string",
          "id": "http://jsonschema.net/name",
          "required": true
      },
      "size": {
          "type": "string",
          "enum": ["S", "M", "L", "XL", "XXL"],
          "id": "http://jsonschema.net/size",
          "required": true
      },
      "stateOrProvince": {
          "type": "string",
          "id": "http://jsonschema.net/stateOrProvince",
          "required": true
      },
      "postalCode": {
        "type": "string",
        "id": "http://jsonschema.net/postalCode",
        "required": true
      }
    }
  }

Paste the expected response definition for a successful POST request:


         
      
1
2
3
4
5
6
7
8
responses:
200:
body:
  application/json:
    example: |
      {
        "orderId": "4321"
      }

Synchronize your Updated RAML File With Anypoint Platform

Notice that your API Sync view now allows you to upload your changes through the Upload button:

api-sync-view-raml-update

You can select your raml file and click the Upload button to submit your chances to Anypoint Platform.

To learn more about this in detail, check our API sync reference page.
You can also navigate to your API Designer to check how the updates were pushed.

Download the final t-shirt RAML definition.