Nav

Create and Publish an API Specification with the Code Editor in Design Center

You can create API specifications directly in RAML with the help of code suggestions that appear within the code editor.

Before you begin

Within Anypoint Platform, you must be assigned the Design Center Developer permission.

About this task

An API specification that is written in RAML typically includes the following things:

  • An optional baseURI node at the root of the RAML document

    If you don’t have an implementation of the API and cannot provide a baseURI, you can still test the API using the mocking service baseURI described below.

  • API resources, for example the collection of all customers or a specific customer

  • HTTP methods, such as GET, POST, PUT, and DELETE, allowed on each resource

  • The representation of the request and response messages for each method,

Procedure

  1. On the Projects page in Design Center, click Create and select API Specification.

  2. In the New API Specification dialog, name your project and select the option Start with API Designer to use the code editor.

    Result: The code editor opens. The editor is divided into three panels:

    • The left panel lists the files in your project. By default, the editor creates a .raml file that has the same name as the project.

      You can create more than one API specification in a single project. If you want to include additional API specifications in your project, click the plus sign in the Files panel to create a new file or click the dots that are next to the plus sign to import a file.

    • The central panel displays the editor in which you create the API specification. Appearing in the editor when you create a project or start a new API specification are the first two lines of a valid .raml file.

    • The right panel lists the types and resources that are in the API specification that is in the central panel.

  3. Draft your API specification.

    As you draft, the code editor suggests RAML nodes, methods, and other elements that you can add at the location of your cursor. While you are working in the editor, you can use a large number of commands to navigate through and manipulate the content of your specification. Press F1 at any time to see a list of them. This list also displays keyboard shortcuts for most of the commands.

    You can also perform these tasks:

    Import files and API fragments into your project

    You can import files, either separately or bundled together in .zip files. The files can be RAML 1.0 files, JSON files, or OpenAPI Specification (OAS) 2.0 files. The files can be on your computer or you can specify a URL for them if they are located online.

    For more information about importing files and steps for how to import them, see "Import Files into an API Project", which is linked to from the See also section at the end of this topic.

    For information about adding API fragments to your project, see "Add an API Fragment to an API-Specification Project as a Dependency", which is linked to from the See also section at the end of this topic.

    Simulate calls to your API

    Even while you are drafting an API specification, you can simulate calls to endpoints for which you have specified

    • An HTTP status code the API returns, if successful

    • An example of data the actual implementation would return

      For more information, view the topic "Simulate Calls to an API", which is linked to from the See also section at the end of this topic.

    Export your API project

    At any time, you can export your project as a .zip file, or an API specification from RAML to OAS 2.0. For more information, view the topic "Export Files from an API Project", which is linked to from the See also section at the end of this topic.

What to do next

Publish your API specification to Exchange. Click the icon that is in the top-right corner of the code editor to open the Publish API specification to Exchange dialog. The icon looks like this:

publish to exchange
Figure 1. Publish to Exchange icon

We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used and to tailor advertising. You can read more and make your cookie choices here. By continuing to use this site you are giving us your consent to do this.

+