Request Response - NeoSOFT-Technologies/rest-dot-net-core GitHub Wiki
Description
Describing Responses
An API specification needs to specify the responses for all API operations. Each operation must have at least one response defined, usually a successful response. A response is defined by its HTTP status code and the data returned in the response body and/or headers.
An API can respond with various media types. JSON is the most common format for data exchange, but not the only one possible. It contains
- HTTP Status Codes -Under responses, each response definition starts with a status code, such as 200 or 404. An operation typically returns one successful status code and one or more error statuses.
- Response Body - The schema keyword is used to describe the response body. Here response body defines Success Status, Message, Error(if any) and Data.
Response That Returns a File - An API operation can return a file, such as an image or PDF.
Describing Request Body
The POST, PUT and PATCH requests can have the request body (payload), such as JSON or XML data. In Swagger terms, the request body is called a body parameter. Many APIs transmit data as an object, such as JSON. Schema for an object should specify type: object and properties for that object. For example, the Event/POST operation with this JSON body:
Demo
Demo video to get the clear result view of above implemented module.