Skip to content

feat: new @typespec/rest-api library with standard REST terminology#3

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/create-new-rest-library
Draft

feat: new @typespec/rest-api library with standard REST terminology#3
Copilot wants to merge 3 commits intomainfrom
copilot/create-new-rest-library

Conversation

Copy link

Copilot AI commented Feb 11, 2026

New TypeSpec library for defining RESTful APIs using widely understood REST terminology. Not based on the existing @typespec/rest package — clean-slate design with breaking changes allowed.

Decorators

  • @resource(collectionName) / @parentResource(parent) — define resources and nested hierarchies
  • @reads, @creates, @updates, @deletes, @lists, @createsOrReplaces — map operations to HTTP verbs
  • @action(name?) / @collectionAction(resourceType, name?) — custom endpoints beyond CRUD

CRUD template interfaces

Composable interfaces: ReadOperations, CreateOperations, UpdateOperations, DeleteOperations, ListOperations, CreateOrReplaceOperations, plus aggregates InstanceOperations, CollectionOperations, and CrudOperations.

Helper models

KeysOf<T>, ParentKeysOf<T>, ResourceKey<T>, CollectionKey<T> for key parameter composition.

Example

import "@typespec/rest-api";
using TypeSpec.RestApi;

@resource("pets")
model Pet {
  @key("petId") id: string;
  name: string;
}

@resource("toys")
@parentResource(Pet)
model Toy {
  @key("toyId") id: string;
  name: string;
}

@error model ApiError { code: int32; message: string; }

interface Pets extends CrudOperations<Pet, ApiError> {}
interface PetToys extends ReadOperations<Toy, ApiError>, ListOperations<Toy, ApiError> {}

19 unit tests covering all decorators, diagnostic validation, and template interfaces.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits February 11, 2026 22:15
…ology

Add new TypeSpec library package for defining RESTful APIs using common REST
terminology including: @resource, @parentResource, @reads, @Creates,
@createsOrReplaces, @updates, @deletes, @lists, @action, @collectionAction
decorators and CRUD operation template interfaces.

Co-authored-by: johanste <15110018+johanste@users.noreply.github.com>
19 tests covering: @resource, @parentResource, resource operation decorators
(@reads, @Creates, @updates, @deletes, @lists, @createsOrReplaces),
@action validation, and CRUD operation template interfaces.

Co-authored-by: johanste <15110018+johanste@users.noreply.github.com>
Copilot AI changed the title [WIP] Create new REST library with breaking changes feat: new @typespec/rest-api library with standard REST terminology Feb 11, 2026
Copilot AI requested a review from johanste February 11, 2026 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants