Commit 5c8a2d8
Add security scheme descriptions to Azure Core data-plane playground sample (#4547)
The Azure Core Data Plane playground sample emitted auth schemes without
`description`, so generated REST docs did not show guidance text for API
key/OAuth2 authentication. This PR updates the sample to model and emit
explicit security scheme descriptions.
- **Problem summary**
- Playground users had no example of how to attach descriptions to
security schemes in TypeSpec Azure data-plane services.
- Generated OpenAPI `securityDefinitions`/`securitySchemes` for the
sample lacked descriptive auth text.
- **Sample update (source)**
- Updated `packages/samples/specs/data-plane/widget-manager/main.tsp`.
- Replaced inline auth types with named auth models and attached doc
comments (`/** ... */`) to each.
- Updated `@useAuth(...)` to reference those named models so auth docs
propagate into emitted OpenAPI.
- **Snapshot/output update**
- Regenerated widget-manager sample outputs:
- `@azure-tools/typespec-autorest/.../openapi.json`
- `@typespec/openapi3/openapi.2022-08-31.yaml`
- Both now include auth scheme `description` fields for API key and
OAuth2 entries.
- **Example**
```tsp
/** Authenticate requests with an API key in the X-Key header. */
model WidgetManagerApiKeyAuth is ApiKeyAuth<ApiKeyLocation.header, "X-Key">;
/** Authenticate requests with OAuth2 using the widget service scope. */
model WidgetManagerOauth2Auth is OAuth2Auth<[
{
type: OAuth2FlowType.implicit,
authorizationUrl: "https://login.contoso.com/common/oauth2/v2.0/authorize",
scopes: ["https://widget.contoso.com/.default"],
}
]>;
@useAuth(WidgetManagerApiKeyAuth | WidgetManagerOauth2Auth)
namespace Contoso.WidgetManager;
```
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
Co-authored-by: Timothee Guerin <tiguerin@microsoft.com>1 parent 364b924 commit 5c8a2d8
3 files changed
Lines changed: 44 additions & 5 deletions
File tree
- packages/samples
- specs/data-plane/widget-manager
- test/output/azure/core/data-plane/widget-manager
- @azure-tools/typespec-autorest/2022-08-31
- @typespec/openapi3
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
17 | 30 | | |
18 | 31 | | |
19 | 32 | | |
| |||
Lines changed: 17 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
24 | 29 | | |
25 | 30 | | |
26 | 31 | | |
27 | | - | |
| 32 | + | |
28 | 33 | | |
| 34 | + | |
29 | 35 | | |
30 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
31 | 46 | | |
32 | 47 | | |
33 | 48 | | |
| |||
Lines changed: 13 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1271 | 1271 | | |
1272 | 1272 | | |
1273 | 1273 | | |
1274 | | - | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
1275 | 1277 | | |
1276 | 1278 | | |
1277 | 1279 | | |
| |||
1684 | 1686 | | |
1685 | 1687 | | |
1686 | 1688 | | |
1687 | | - | |
| 1689 | + | |
1688 | 1690 | | |
1689 | 1691 | | |
1690 | 1692 | | |
| 1693 | + | |
| 1694 | + | |
| 1695 | + | |
| 1696 | + | |
| 1697 | + | |
| 1698 | + | |
| 1699 | + | |
| 1700 | + | |
| 1701 | + | |
0 commit comments