Search Results

Adding and Editing Responses

A method must contain at least one response definition. A default response is added for each method in a resource. It uses the default response object for all HTTP codes that are not covered individually by the specification.

Click the method that you want to add response for and click Response.

Adding a Response

To add a response, complete these steps:

  1. In the Response Content Type section, select a response content type from the following options:
    • application/json: the response content must be in JSON format. By default, this option is selected.
    • application/xml: the response content must be in XML format.
  2. Click Add to add a response.

  3. In the HTTP status code field, enter a unique status code. The HTTP status codes are used to indicate the response status of the executed operation.
  4. Enter a description for the entered status code.
  5. Click next to Headers to add a response header:

    • In the Name field, enter a header name.
    • From the data type list, select a data type for the response header. By default, the data type is string.
    • (Optional) Select the array check box if the response header is array.
    • (Optional) In the Description field, enter a description for the added response header.
    • (Optional) In the Default value field, enter a default value.
  6. There are three methods to add the response schema:

    • You can model your schema from sample JSON data, and API Modeler will automatically generate a corresponding JSON schema object type.

      Enter sample JSON data for your response in the Provide Sample Data box. This can be a JSON object or JSON array. The data will be validated as you type it, and a message in the lower left will indicate if the sample data is valid.

      After entering valid sample data, click Generate Schema. The schema editor page will appear, with your sample data converted into a schema in the schema editor box.

    • To directly enter a complete JSON schema, click Input Schema. The schema editor page will appear, with a blank schema box. Enter your JSON schema in the box.

    • To use an existing schema, click Input Schema. The schema editor page will appear. Enter the name of the existing schema in the schema name box. The schema box will then be filled with the existing schema you selected. The scope of the existing schemas is within the same API specification.

    Note: The schema you enter cannot start from a root element name, such as the below schema which starts from a root element "book":

     "book": {
         "type": "object",
         "properties": {
  7. If you modeled your schema or entered a complete schema, enter a unique name in the schema name box.

    Note: If you enter an existing name, and choose this name in the auto-search results in the schema name box, the existing schema will be extracted and replace the schema you just modeled. if you enter an existing name and click Save without choosing the name from the list, the new schema will overwrite the existing schema under the name.

  8. You can make further changes to the complete schema in the schema box, if required.

  9. Select a response schema from the following options:
    • String: the response content can be any string.
    • Reference: the request content must conform to the referenced JSON schema. This will be selected if you have entered or modeled a schema.
    • None: no response content.
  10. Select the array check box if the response body is an array of a string, or an array of the JSON object conforming to the schema referenced.

  11. You can click Generate Schema from Sample Data to return to the Edit Response page with the Provide Sample Data box visible. This enables you to start over and enter new sample data. Note that the new generated schema will overwrite the existing schema. You must confirm that you wish to do this.

  12. Click Save when you are finished.

Editing a Response

To edit an added response, click the response card; To remove a defined response, move the mouse pointer over the response and click .

You can drag the response card to change the position of the added response. By default, the response cards are placed from the small HTTP status code to the large.

What to Do Next

Previewing and Exporting API