Nav

Create and Publish an API Fragment in the Code Editor in Design Center

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

About this task

An API fragment is a RAML document that has a version and an identifier, but is not in itself a complete RAML specification. An API fragment is one of the following types defined by RAML.org:

  • Trait

  • Resource Type

  • Library

  • Type

  • User Documentation

  • Example

  • Annotation Type

  • Security Scheme

Procedure

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

  2. In the New API Fragment dialog, type a name for the project and select the type of API fragment that you want to create. Then, click Create.

    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 your API fragment.

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

  3. Draft your API fragment.

    As you draft, the code editor suggests RAML nodes, methods, and other elements that you can add at the location of your cursor.

    You can import files into your project, 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.

What to do next

You can publish the API fragment to Anypoint 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

The fragment can then be included as a dependency in an API-specification project. After revising a fragment, update API specifications that use the fragment to include the new version.