Skip to content

What's the correct/swagger way to document the request body of a POST method that posts a complex object? #391

@mikemil

Description

@mikemil

We are using Swagger but writing the JSON manually (for now - will get automated later). We have some resources that use POST and the post body is a complex object representation in either XML or JSON.

I have tried the following - but haven't really seen any good examples. I have the paramType of body and the dataType as Customer. Is this how you intended this?

The demo project only shows GET requests and really doesn't include a good set of sample coverage of the different parameter types, etc.

partial snippet:
{
"path": "/v1/customers",
"operations": [
{
"method": "POST",
"summary": "Creates a new customer",
"notes": "Creates a new customer using the given customer object.",
"responseClass": "Customer",
"nickname": "",
"produces": [
"application/json",
"application/xml"
],
"parameters": [
{
"name": "body",
"description": "Customer object",
"required": true,
"allowMultiple": false,
"dataType": "Customer",
"paramType": "body"
}
],
"errorResponses": [
{
"code": 400,
"message": "Bad Request. Customer was not created."
}
]
}
]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions