Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ It is not published as an npm package.
Samples should teach a distinct TypeSpec concept or realistic workflow. Narrow protocol test
cases belong in the relevant package test suite instead of this collection.

Each sample directory has a `sample-config.yaml` containing a unique `title` and a
`description`. Set `playground: false` for samples that require multiple files or are not suitable
for the playground. A directory config uses `directory: true` and can provide a gallery `label`,
`danger`, or an inherited `playground: false`.

```bash
npm run test # Check Samples match snapshots
npm run test:ci # run test same as CI
Expand Down
3 changes: 2 additions & 1 deletion packages/samples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
"@typespec/rest": "workspace:^",
"@typespec/sse": "workspace:^",
"@typespec/streams": "workspace:^",
"@typespec/versioning": "workspace:^"
"@typespec/versioning": "workspace:^",
"yaml": "catalog:"
},
"devDependencies": {
"@types/node": "catalog:",
Expand Down
3 changes: 3 additions & 0 deletions packages/samples/specs/authentication/sample-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title: Authentication
description: Apply authentication schemes at service, interface, and operation scope.
playground: false
3 changes: 3 additions & 0 deletions packages/samples/specs/binary/sample-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title: Binary data
description: Model binary request and response payloads.
playground: false
3 changes: 3 additions & 0 deletions packages/samples/specs/documentation/sample-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title: Documentation
description: Add documentation to TypeSpec declarations and emitted API descriptions.
playground: false
2 changes: 2 additions & 0 deletions packages/samples/specs/emitters/graphql/sample-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title: GraphQL
description: Generate a GraphQL schema with queries, mutations, models, and enums.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title: JSON Schema
description: Generate JSON Schema documents from TypeSpec models and constraints.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title: Protobuf kiosk
description: Generate Protocol Buffer service and message definitions for a kiosk system.
2 changes: 2 additions & 0 deletions packages/samples/specs/emitters/sample-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
directory: true
label: Emitters
3 changes: 3 additions & 0 deletions packages/samples/specs/encoded-names/sample-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title: Encoded names
description: Customize declaration names for specific emitters.
playground: false
3 changes: 3 additions & 0 deletions packages/samples/specs/encoding/sample-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title: Value encoding
description: Configure serialization formats for scalar values.
playground: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title: HTTP service
description: Build an HTTP service with routes, parameters, request bodies, and responses.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title: REST framework
description: Use resource-oriented REST templates to define a service with less repetition.
2 changes: 2 additions & 0 deletions packages/samples/specs/getting-started/sample-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
directory: true
label: Getting Started
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title: Advanced gRPC kiosk
description: Demonstrate a multi-file Protobuf-oriented kiosk service.
playground: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title: Protobuf library
description: Build and consume reusable Protobuf declarations.
playground: false
3 changes: 3 additions & 0 deletions packages/samples/specs/init/sample-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title: Project initialization
description: Show the service generated by the TypeSpec project initializer.
playground: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title: API versioning
description: Evolve an API across versions with version-aware types and operations.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title: Discriminated unions
description: Model polymorphic values with a discriminated union.
2 changes: 2 additions & 0 deletions packages/samples/specs/language/sample-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
directory: true
label: Language
3 changes: 3 additions & 0 deletions packages/samples/specs/local-typespec/sample-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title: Local TypeSpec installation
description: Configure an editor to use a project-local TypeSpec compiler.
playground: false
3 changes: 3 additions & 0 deletions packages/samples/specs/multipart/sample-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title: Multipart requests
description: Define multipart form data with files and structured fields.
playground: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title: OpenAPI extensions
description: Attach custom OpenAPI extensions to emitted declarations.
playground: false
3 changes: 3 additions & 0 deletions packages/samples/specs/param-decorators/sample-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title: Parameter decorators
description: Apply decorators through reusable operation parameters.
playground: false
3 changes: 3 additions & 0 deletions packages/samples/specs/petstore/sample-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title: Extensible Pet Store
description: Extend TypeSpec with a local decorator and custom project files.
playground: false
3 changes: 3 additions & 0 deletions packages/samples/specs/polymorphism/sample-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title: Polymorphic models
description: Model inheritance and discriminated polymorphic responses.
playground: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title: REST metadata emitter
description: Inspect REST metadata from a custom emitter.
playground: false
3 changes: 3 additions & 0 deletions packages/samples/specs/rest/petstore/sample-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title: REST Pet Store
description: Define a resource-oriented Pet Store service.
playground: false
3 changes: 3 additions & 0 deletions packages/samples/specs/signatures/sample-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title: Operation signatures
description: Compare operation declaration and template signatures.
playground: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title: Status code ranges
description: Describe HTTP responses covering status code ranges.
playground: false
3 changes: 3 additions & 0 deletions packages/samples/specs/string-template/sample-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title: String templates
description: Construct values using TypeSpec string templates.
playground: false
3 changes: 3 additions & 0 deletions packages/samples/specs/tags/sample-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title: OpenAPI tags
description: Group emitted operations with tags.
playground: false
3 changes: 3 additions & 0 deletions packages/samples/specs/todoApp/sample-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title: Todo application
description: Define a complete HTTP API for a small todo application.
playground: false
3 changes: 3 additions & 0 deletions packages/samples/specs/use-versioned-lib/sample-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title: Versioned library
description: Consume a library whose API evolves across versions.
playground: false
3 changes: 3 additions & 0 deletions packages/samples/specs/versioning/sample-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title: Advanced versioning
description: Coordinate service and library versions across multiple files.
playground: false
3 changes: 3 additions & 0 deletions packages/samples/specs/visibility/sample-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title: Lifecycle visibility
description: Control how model properties participate in lifecycle operations.
playground: false
1 change: 1 addition & 0 deletions packages/samples/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from "./sample-config.js";
export * from "./sample-snapshot-testing.js";
Loading
Loading