Generating REST API as service provider

Once you have finished the modeling of your REST Resource(s), you can generate the API and optionally, the API documentation.

Generating REST API

To generate REST API:

  1. Select Tools > Code > Generate REST API... from the toolbar.
  2. In the REST API window, keep Provider selected for API Type. By doing so, you will be able to generate API documentation as well as the server sample code that guides you in programming your service (logic).
  3. Select the REST Resource to generate to code.
    Select the REST Resource to be generated
    Select the REST Resource to be generated
  4. The generator will use the templates stored in the Template directory for code generation. You may edit the templates or select another directory as template directory.
  5. Check Generate API Documentation to generate the HTML files that shows how to use the selected REST Resource(s). Supposedly, you will publish the generated API documentation in your website so that the consumers of your service can read through it to know how to access for your service.
  6. Enter your company name, which will be presented in the API documentation.
  7. Enter the base URL of your services.
  8. Check Generate Sample to generate the source code that teaches you how to program your service. The sample code is rich and informative. Therefore, instead of programming from scratch, we strongly recommend you to generate the sample code and modify its content to fit your needs.
  9. Enter the output path of the code.
    Output path entered
    Output path entered
  10. Click Generate. Depending on the option checked/unchecked, you may see the following folders in the output directory.
    Folder Description
    doc The API documentation. You should publish the API documentation in your website, so that the consumers of your service can check the documentation to learn the API.
    lib In order for the generated code to work, the Google Gson library must be presented in your class path. To avoid any compatibility issues, please download library manually:
    https://code.google.com/p/google-gson/

    and then place the file in the lib folder.
    sample_src The sample code of client and servlet. It shows you how to access as client and how to react to a request as provider. We strongly recommend you to copy the code and modify it by filling in your own service logic.
    src The source code of the communication model. Do not modify the file content or else the code may not be able to function properly.
    Description of generated files

Related Resources

The following resources may help you to learn more about the topic discussed in this page.

 
2. Modeling REST API Table of Contents 4. Using REST API (as a Service Consumer)
 

Technical Support

Have technical issues or suggestions? Please contact Visual Paradigm Support Team.

Sales Support

Have questions related to registration, licensing or payment? Feel free to contact Visual Paradigm Sales Team.

Discussion Forum

Share your suggestions of opinions at VP Discussion Forum.