You can generate a Java API for RESTful Web Services (JAX-RS) 2.0 client in a Java™
Platform, Enterprise Edition (Java EE) 7 web project. This JAX-RS 2.0 client is based on a REST API
definition file that is named swagger.json.
About this task
Important: Applicable to Liberty
Procedure
- Open the Generate JAX-RS Client wizard by completing one of the following
options:
- Enter the location of the swagger.json file.
The swagger.json file can be in the workspace or the file system. You can
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.
- Select the target Java EE 7 web project from the Project drop-down
menu.
Tip: Select a different project than the service project that contains the
swagger.json file. Ensure that the JAX-RS 2.0 facet is enabled for the Java EE
7 target project.
- In the Source Folder field, enter the target source folder that is defined
in the project.
- In the Package field, enter the Java package of the generated client
code.
- 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 with
the suffix
.api. You can use the API classes in this package to invoke REST
services.