You can use WebSphere Developer Tools to generate a Java API for RESTful Web Services
(JAX-RS) 2.0 client into a web project. This JAX-RS 2.0 client is based on a REST API definition
file that is named swagger.json.
Procedure
- Open the Generate JAX-RS Client wizard by completing one of the following
options:
- In the Swagger Definition field, enter the location of your
swagger.json file.
The swagger.json file can be in the workspace or the file system, or it can
be an HTTP or file:// reference.
- Select the target project type from the Project drop-down menu.
Tip: Generate client code in different project than the service project that contains
the swagger.json file.
- In the Source Folder field, enter the target source folder that is defined
in the project.
- In the Package field, enter the location of the web package.
- Click Finish.
Results
You generated a JAX-RS 2.0 client in the web project that you targeted. The
Generate JAX-RS Client wizard creates four packages, including a
package_name.api file. You can use the API classes in the
package_name.api file to invoke REST services.