This document provides examples specific to the HTTP library in TypeSpec. For general information about how examples work in TypeSpec, see the examples docs.
Multiple responses
When defining HTTP operations, you often need to document different possible response types based on status codes. The @opExample decorator allows you to provide sample responses for each status code your operation might return.
In the example below, we define an operation that can return three different responses (200 OK, 404 Not Found, and 422 Unprocessable Entity), with examples for each: