0

I'd like to add JSON as the default to this swagger endpoint for the body of the POST request. I can not for the life of me figure out what this format is supposed to be to add a very large JSON object as the default for a POST endpoint. See example swagger spec below

{
  "consumes": [
    "application/x-www-form-urlencoded"
  ],
  "definitions": {},
  "info": {
    "title": "swagger help",
    "version": "1.0"
  },
  "paths": {
    "/endpoint_name": {
      "post": {
        "consumes": [
          "application/json"
        ],
        "parameters": [
          {
            "default": {
              "application/json": [{"test": "value"}]
            },
            "description": "JSON of a list of values",
            "in": "body",
            "name": "body",
            "required": true,
            "type": "object"
          }
        ],
        "produces": [
          "application/json"
        ],
        "security": [
          {
            "APIKeyHeader": [
              "Authorization"
            ]
          }
        ],
      }
    },
  "produces": [
    "application/json"
  ],
  "securityDefinitions": {
    "APIKeyHeader": {
      "description": "description here",
      "in": "header",
      "name": "Authorization",
      "type": "apiKey"
    }
  },
  "swagger": "2.0"
}
Justin Furuness
  • 685
  • 8
  • 21

1 Answers1

0

In OpenAPI 2.0, body parameters use the schema keyword. That's where you specify the type, default, example, and other type-related details.

        "parameters": [
          {
            "description": "JSON of a list of values",
            "in": "body",
            "name": "body",
            "required": true,
            "schema": {
              "type": "object",
              "default": {"test": "value"}
            }
          }
        ],
Helen
  • 87,344
  • 17
  • 243
  • 314