Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@typespec/rest

Package Overview
Dependencies
Maintainers
2
Versions
106
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@typespec/rest

TypeSpec REST protocol binding

  • 0.63.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
65K
increased by5.36%
Maintainers
2
Weekly downloads
 
Created
Source

@typespec/rest

TypeSpec REST protocol binding

Install

npm install @typespec/rest

Decorators

TypeSpec.Rest

@action

Specify this operation is an action. (Scoped to a resource item /pets/{petId}/my-action)

@TypeSpec.Rest.action(name?: valueof string)
Target

Operation

Parameters
NameTypeDescription
namevalueof stringName of the action. If not specified, the name of the operation will be used.
@actionSeparator

Defines the separator string that is inserted before the action name in auto-generated routes for actions.

@TypeSpec.Rest.actionSeparator(seperator: valueof "/" | ":" | "/:")
Target

Model | ModelProperty | Operation

Parameters
NameTypeDescription
seperatorvalueof "/" | ":" | "/:"Seperator seperating the action segment from the rest of the url
@autoRoute

This interface or operation should resolve its route automatically. To be used with resource types where the route segments area defined on the models.

@TypeSpec.Rest.autoRoute
Target

Interface | Operation

Parameters

None

Examples
@autoRoute
interface Pets {
  get(@segment("pets") @path id: string): void; //-> route: /pets/{id}
}
@collectionAction

Specify this operation is a collection action. (Scopped to a resource, /pets/my-action)

@TypeSpec.Rest.collectionAction(resourceType: Model, name?: valueof string)
Target

Operation

Parameters
NameTypeDescription
resourceTypeModelResource marked with
namevalueof stringName of the action. If not specified, the name of the operation will be used.
@copyResourceKeyParameters

Copy the resource key parameters on the model

@TypeSpec.Rest.copyResourceKeyParameters(filter?: valueof string)
Target

Model

Parameters
NameTypeDescription
filtervalueof stringFilter to exclude certain properties.
@createsOrReplacesResource

Specify that this is a CreateOrReplace operation for a given resource.

@TypeSpec.Rest.createsOrReplacesResource(resourceType: Model)
Target

Operation

Parameters
NameTypeDescription
resourceTypeModelResource marked with
@createsOrUpdatesResource

Specify that this is a CreatesOrUpdate operation for a given resource.

@TypeSpec.Rest.createsOrUpdatesResource(resourceType: Model)
Target

Operation

Parameters
NameTypeDescription
resourceTypeModelResource marked with
@createsResource

Specify that this is a Create operation for a given resource.

@TypeSpec.Rest.createsResource(resourceType: Model)
Target

Operation

Parameters
NameTypeDescription
resourceTypeModelResource marked with
@deletesResource

Specify that this is a Delete operation for a given resource.

@TypeSpec.Rest.deletesResource(resourceType: Model)
Target

Operation

Parameters
NameTypeDescription
resourceTypeModelResource marked with
@listsResource

Specify that this is a List operation for a given resource.

@TypeSpec.Rest.listsResource(resourceType: Model)
Target

Operation

Parameters
NameTypeDescription
resourceTypeModelResource marked with
@parentResource

Mark model as a child of the given parent resource.

@TypeSpec.Rest.parentResource(parent: Model)
Target

Model

Parameters
NameTypeDescription
parentModelParent model.
@readsResource

Specify that this is a Read operation for a given resource.

@TypeSpec.Rest.readsResource(resourceType: Model)
Target

Operation

Parameters
NameTypeDescription
resourceTypeModelResource marked with
@resource

Mark this model as a resource type with a name.

@TypeSpec.Rest.resource(collectionName: valueof string)
Target

Model

Parameters
NameTypeDescription
collectionNamevalueof stringtype's collection name
@segment

Defines the preceding path segment for a

@TypeSpec.Rest.segment(name: valueof string)
Target

Model | ModelProperty | Operation

Parameters
NameTypeDescription
namevalueof stringSegment that will be inserted into the operation route before the path parameter's name field.
Examples
@segmentOf

Returns the URL segment of a given model if it has @segment and @key decorator.

@TypeSpec.Rest.segmentOf(type: Model)
Target

Operation

Parameters
NameTypeDescription
typeModelTarget model
@updatesResource

Specify that this is a Update operation for a given resource.

@TypeSpec.Rest.updatesResource(resourceType: Model)
Target

Operation

Parameters
NameTypeDescription
resourceTypeModelResource marked with

Keywords

FAQs

Package last updated on 11 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc