Contact Free trial Login

Create and Publish a RAML API Fragment in the Text Editor in API Designer

You can create API fragments directly in RAML with the help of code suggestions that appear within the text 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. See the RAML 0.8 or 1.0 specification (depending on which you want to use) for descriptions of the types.

  • 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 Create Fragment.

  2. In the New Fragment dialog, type a name for the project. You can change the name (but not the extension) later, if you want to.

  3. Select the type of API fragment that you want to create and click Create Fragment.

    Result: The text 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. This file is set as the root file of the project.

      The left panel also lists the file exchange.json, which is a file that contains metadata required by Anypoint Exchange at the time that you publish your project to Exchange. This file is read-only.

    • 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.

  4. Draft your API fragment.

    As you draft, the text 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.

What to Do Next

You can publish the API fragment to Anypoint Exchange.

  1. Click the Publish button that is in the top-right corner of the text editor, and then click Publish to Exchange.

  2. Specify a version number for the project, which Exchange treats as an asset. This number is displayed in Exchange in the Version section of the right pane in the page for the project.

In Anypoint Exchange, the asset version of your API-fragment project appears here.

The location of the Versions section

After you publish the API-fragment project, other developers can include its fragments as dependencies in their own API-specification projects.

When you publish the API-fragment project, Exchange automatically creates an API portal for it.