Skip to content

Adding Parameters & Headers in Martini

Parameters

Parameters in Martini's REST API are integral to mapping HTTP request data to the input properties of a service. The editor in Martini simplifies this mapping process, thanks to clearly defined service inputs. There are several methods to add a parameter to an operation:

  1. Using the New Parameter Button

    • Located in the toolbar, this button is accessible when an operation is selected.
    • Clicking this button adds a new parameter under the 'Parameters' node.
    • A dropdown menu allows you to choose the parameter type, offering choices based on the selected service's input properties.
  2. Context Menu in the Editor

    • Right-click on a 'Parameters' node to access this menu.
    • This method allows for quick and contextual addition of parameters.
  3. Using Content-Assist

    • This feature is engaged within the editor, enabling the selection of 'Parameter'.
    • Martini prompts you to choose an input property and its location.
    • If located under the 'Parameter' node, Martini lists the input properties for straightforward selection.

Parameter Locations

Parameters in Martini can be found in various parts of the HTTP request:

  • Path: Incorporated into the URL, but excluding the host or base path. For example, in /items/{itemId}, itemId is a path parameter.
  • Query: Parameters appended to the URL. For example, in /items?id=###, id is a query parameter.
  • Header: Custom headers expected in the request, which are case-insensitive as stated in RFC7230.
  • Cookie: Specific cookie values passed to the API. Swagger's lack of support for cookie parameters means Martini logs a warning when they are used.
  • Form: Parameters defined following the style of forms as per RFC6570.

Each parameter has a 'Description' field for a brief explanation or usage examples, supporting CommonMark syntax for formatted text.

Request Bodies

When an HTTP request method allows for request bodies, a 'Body Parameter' node is visible under the corresponding operation node. To set the body parameter:

  1. Direct Selection and Editing

    • Select the 'Body Parameter' node and engage the editing mode.
    • A dropdown menu enables the selection of the service input property to map as the request body.
  2. Content-Assist Feature

    • This can be activated in the editor, facilitating the selection of existing input properties or the addition of a new property for the 'Body Parameter' field.