Skip to content

Martini Generating Services when Consuming REST APIs

Martini enables developers to integrate RESTful web services by generating services from API schemas. The process is streamlined within Martini's interface. Follow these steps to generate services specifically designed to consume REST APIs.

Steps to Generate Services from a REST API Schema

  1. Navigate to the Consume API Interface

    • In Martini, locate the Navigator view.
    • Within the code folder of your target package, right-click where you want your generated services to be located.
  2. Begin the API Consumption Process

    • From the context menu, select "Consume API" to start generating services from an API schema.
  3. Select the REST API Schema Type

    • A dialog box titled "Consume an API" will appear, presenting a list of API schema types.
    • To specifically consume a REST API, choose the "REST APIs" option to ensure the service generation process is tailored for RESTful web services.
  4. Provide the REST API Schema Source

    • Input the source of your REST API schema in the "File/URL" field. This can be done by either dropping or browsing to a local file, or by entering the URL of the API specification.
    • Click the "Browse" button if you need to navigate to the file on your local system.
  5. Configure Additional Settings

    • Verify that the "Location" field accurately reflects the path within your project for the services.
    • If you want to track the requests for debugging purposes, select the "Log requests to Tracker" checkbox.
  6. Finalize and Generate

    • After all the details are correctly filled in, click the "Consume" button. Martini will process the REST API schema and generate the corresponding services.

Note for Secured REST APIs

For secured REST APIs, authentication is essential. Martini supports both basic authentication and OAuth2. Make sure to provide the authentication details as the generated services will have input properties for these credentials and an authType property indicating the authentication type.

Review and Customize the Generated Services

It's important to review the generated services and customize them as needed. This includes validating the service logic, adjusting input and output models, and setting up error handling for a robust integration.