Generating a JAX-RS Service from a REST API definition file

Generate a Java™ application programming interface (API) for a RESTful Web Services (JAX-RS) service in a Java Platform, Enterprise Edition (Java EE) 7 web project. This JAX-RS service is based on a REST API definition file that is named swagger.json.

About this task

Important: Applicable to Liberty, WebSphere® Application Server traditional

Procedure

  1. Open the Generate JAX-RS Service wizard by completing one of the following options:
    • Right-click a swagger.json file in your workspace and select RESTful Services > Generate JAX-RS Service.

      The tools display the Generate JAX-RS Service window.

    • Complete the following steps to open the Generate the JAX-RS Service wizard from the New Wizard window:
      1. From the Eclipse workbench, select File > New > Other....

        The tools display the New Wizard window.

      2. Select RESTful Services > Generate JAX-RS Service.
      3. Click Next.

        The tools display the Generate JAX-RS Service window.

  2. If the Swagger Definition field is empty, enter the location of your swagger.json file.

    The swagger.json file exists in the workspace or the file system. Provide an HTTP or file:// reference. If you right-clicked your swagger.json file in the previous step, the location is already entered. You can also drag your swagger.json file from an external file system to this field.

  3. Select the target Java EE 7 web project from the Project drop-down menu.
    Tip: Ensure that the JAX-RS 2.0 facet is enabled for the Java EE 7 target project.
  4. In the Source Folder field, enter the target source folder that is defined in the project.
  5. In the Package field, enter the Java package of the generated service code.
  6. Click Finish.

Results

You generated a JAX-RS service in the web project that you targeted. The Generate JAX-RS Service wizard creates API and model packages. The JAX-RS resources reside in the API package.