Skip to content

Instantly share code, notes, and snippets.

@who
Created June 17, 2015 19:12
Show Gist options
  • Save who/e53a0fff078e6bb26e8c to your computer and use it in GitHub Desktop.
Save who/e53a0fff078e6bb26e8c to your computer and use it in GitHub Desktop.

This method ...

    @POST
    @Path("/strings")
    @ApiOperation(value = "Send a string in the body",
        nickname = "gimmieString",
        authorizations = @Authorization(value = "basicAuth"))
    public String gimmieString(@ApiParam("theString") String theString, @Auth User user) {
        return "you sent: "+ theString;
    }

... yields this spec:

...
"/strings" : {
    "security": [
      {
        "basicAuth": []
      }
    ],
    "responses": {
      "200": {
        "schema": {
          "type": "string"
        },
        "description": "successful operation"
      }
    },
    "parameters": [
      {
        "schema": {
          "type": "string"
        },
        "required": false,
        "description": "theString",
        "name": "body",
        "in": "body"
      },
      {
        "schema": {
          "$ref": "#/definitions/User"
        },
        "required": false,
        "name": "body",
        "in": "body"
      }
    ],
    "produces": [
      "application/json"
    ],
    "operationId": "gimmieString",
    "description": "",
    "summary": "Send a string in the body",
    "tags": [
      "Bundle Resource"
    ]
  }

}
...

Notice how there are two body parameters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment