[8.5.5.8 or later]

Creating a REST API definition file

You can use a wizard to generate a template swagger.json file to specify a Representational State Transfer (REST) application programming interface (API). The wizard is enabled for projects that target a Liberty server and use Web 2.5 and above.

About this task

Important: Applicable to Liberty, Liberty Core

Procedure

  1. Create a web project that targets a Liberty server.

    For more information about creating web projects, see Creating web projects.

  2. To create a Swagger REST API definition file, complete one of the following options:
    • Select File > New > Other, and then select Swagger REST API definition file in the REST API definition section.
    • Right-click a project and select New > Swagger REST API definition file.
  3. To select the type of JavaScript Object Notation (JSON) file that you want to create, complete one of the following options:
    • To create a file with all of the top-level Swagger elements that are required, select Create a swagger.json template file.
    • To create a file with sample contents for common definitions, such as GET, PUT, and POST, select Create a swagger.json sample file.
  4. [8.5.5.9 or later]Select a location for the file that you are creating:
    • To work with Swagger annotations, select Generate as stub document (META-INF/stub directory).
    • If you are not working with Swagger annotations, select Generate as top level document (META-INF directory).
      Note: This option is selected by default.
  5. Click Finish.

Results

The tools generate a swagger.json file in the WebContent/META-INF folder for your web project. The file opens in your default JSON editor.

Icon that indicates the type of topic Task topic
Timestamp icon Last updated: July 17, 2017 21:58

File name: t_restapi_create.html