{"id":14156021,"url":"https://github.com/APIPatterns/typespec-demo","last_synced_at":"2025-08-06T02:31:17.327Z","repository":{"id":115562122,"uuid":"576953392","full_name":"APIPatterns/typespec-demo","owner":"APIPatterns","description":"Demo of TypeSpec","archived":false,"fork":false,"pushed_at":"2023-09-04T14:40:02.000Z","size":160,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-17T08:06:26.018Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/APIPatterns.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-11T14:24:49.000Z","updated_at":"2024-06-11T03:46:39.000Z","dependencies_parsed_at":"2024-05-11T18:28:39.046Z","dependency_job_id":null,"html_url":"https://github.com/APIPatterns/typespec-demo","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/APIPatterns%2Ftypespec-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/APIPatterns%2Ftypespec-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/APIPatterns%2Ftypespec-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/APIPatterns%2Ftypespec-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/APIPatterns","download_url":"https://codeload.github.com/APIPatterns/typespec-demo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228829028,"owners_count":17978136,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-17T08:05:09.770Z","updated_at":"2024-12-09T03:30:56.756Z","avatar_url":"https://github.com/APIPatterns.png","language":"JavaScript","readme":"# TypeSpec Demo\n\nThis repo contains a demo of the TypeSpec API Design language. You can see a [step-by-step walk through of this TypeSpec demo](https://aka.ms/marktalkstypespec/typespec-demo) in Mark's interview by Josh from Zuplo. \n\n## Create a new TypeSpec project\n\nOpen the TypeSpec docs at https://aka.ms/typespec and click on the Installation tab.\n\nFollow the steps there to create a new TypeSpec project.\n\n## Create a new TypeSpec definition\n\nOpen the TypeSpec playground at https://aka.ms/trytypespec and select the Http service example.\n\nView the SwaggerUI by choosing it from the dropdown in the right pane.\n\nMake a few small changes and then copy to the main.tsp file.\n\n## TypeSpec support for reuse\n\nCreate library.tsp with Error model and ResourceTemplate templated interface.\n\nRefactor Widgets interface to use ResourceTemplate then add Gadgets interface.\n\n## API Guidelines -- error response\n\nMake the standard error response conform to the [Azure REST API Guidelines](https://github.com/microsoft/api-guidelines/blob/vNext/azure/Guidelines.md#handling-errors), in particular:\n\n✅ DO return an x-ms-error-code response header with a string error code indicating what went wrong.\n\n✅ DO provide a response body with the following structure:\n\n## API Guidelines -- standard operations\n\nUpdate list operation to conform to [Azures guidelines for operations on collections](https://github.com/microsoft/api-guidelines/blob/vNext/azure/Guidelines.md#collections), in particular:\n\n✅ DO structure the response to a list operation as an object with a top-level array field containing the set (or subset) of resources.\n\n✅ DO return a nextLink field with an absolute URL that the client can GET in order to retrieve the next page of the collection.\n\n☑️ YOU SHOULD use value as the name of the top-level array field unless a more appropriate name is available.\n\nChange the create operation from post to put to [ensure idempotency](https://github.com/microsoft/api-guidelines/blob/vNext/azure/Guidelines.md#exactly-once-behavior--client-retries--service-idempotency).\n\n✅ DO ensure that all HTTP methods are idempotent.\n\n☑️ YOU SHOULD use PUT or PATCH to create a resource as these HTTP methods are easy to implement, allow the customer to name their own resource, and are idempotent.\n\nInclude an update operation (patch) that accepts JSON merge patch and a delete operation that returns a 204 response.\n\n DO create and update resources using PATCH [RFC5789] with JSON Merge Patch (RFC7396) request body.\n\n✅ DO return a 204-No Content without a resource/body for a DELETE operation\n\n## API Guidelines -- api-version query parameter\n\nUpdate all operations in the ResourceTemplate interface to support versioning with an [api-version query parameter](https://github.com/microsoft/api-guidelines/blob/vNext/azure/Guidelines.md#api-versioning).\n\n✅ DO use a required query parameter named api-version on every operation for the client to specify the API version.\n\n✅ DO use YYYY-MM-DD date values, with a -preview suffix for preview versions, as the valid values for api-version.\n\n## Add linter for api-version\n\nCreate linter.js to check operations for api-version and import into library.tsp.\n\nRun tsp compile to show that it flags the Widgets analyze operation as needing an api-version.\n","funding_links":[],"categories":["others","JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAPIPatterns%2Ftypespec-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAPIPatterns%2Ftypespec-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAPIPatterns%2Ftypespec-demo/lists"}