Swagger 2.0 Examples Support Added

Release DateJul 14, 2017
Change Type
Platforms Affected

    Swagger supports response and schema examples as can be seen from their documentation on adding examples. If your API description contains response or schema examples, then the exported Swagger file will be populated with these examples.

    Details

    Many API description formats support response or schema examples e.g. a RAML 1.0 file can contain a schema example as follows:

      Email:
        type: object
        properties:
          subject: string
          body: string
        example:
          subject: My Email 1
          body: This is the text for email 1.
    

    When exporting to Swagger 2.0, this example will look like:

        "Email": {
          "title": "Email",
          "example": {
            "subject": "My Email 1",
            "body": "This is the text for email 1."
          },
          "type": "object",
          "properties": {
            "subject": {
              "description": "",
              "type": "string"
            },
            "body": {
              "description": "",
              "type": "string"
            }
          },
          "required": [
            "subject",
            "body"
          ]
        }
    

    Related Links


    Have questions? Submit a request.