From the course: Building APIs with Swagger and the OpenAPI Specification

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Response objects

Response objects - REST Tutorial

From the course: Building APIs with Swagger and the OpenAPI Specification

Start my 1-month free trial

Response objects

- [Instructor] The component section of an API definition can include objects other than schemas. Using the auto-completion feature, that we can define as reusable components. You'll notice that we're able to specify request bodies, headers, and responses. Let's go ahead and build out a standard response You'll notice that we could define these errors within each operation themselves, buy putting a status code underneath the operation Instead, we're going to create the response within the component section for reusability. The first thing we'll need to do under the response object is name our new response. a response named 500 API error, and then we'll go ahead and underneath that object, we'll define what it looks like. so we'll say this is an unexpected error, and then we'll go ahead and describe what the actual data returned to the API client will look like. So we can specify the content object and within that we can still specify a media type. We're going to be using json once…

Contents