microsoft/typespec

Public

mirrored from https://github.com/microsoft/typespecAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
cba630b21fdb4a073e2a317d646c351e3ece7cc6

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

docs/libraries/http/examples.md

28lines · modepreview

---
title: Examples
---

See [examples docs](../../standard-library/examples.md) for general information about examples.

## Multiple responses

```tsp tryit="{"emit": ["@typespec/openapi3"]}"
import "@typespec/http";

using Http;

@opExample(#{ returnType: #{ statusCode: 200, name: "Max", age: 3 } })
@opExample(#{ returnType: #{ statusCode: 404, error: "Not found" } })
@opExample(#{ returnType: #{ statusCode: 422, error: "Invalid payload" } })
op read(): {
  @statusCode statusCode: 200;
  name: string;
  age: int32;
} | {
  @statusCode statusCode: 404;
  error: string;
} | {
  @statusCode statusCode: 422;
  error: string;
};
```