Decorators
TypeSpec.Rest
Section titled “TypeSpec.Rest”@action
Section titled “@action”Specify this operation is an action. (Scoped to a resource item /pets/{petId}/my-action)
@TypeSpec.Rest.action(name?: valueof string)
Target
Section titled “Target”Operation
Parameters
Section titled “Parameters”Name | Type | Description |
---|---|---|
name | valueof string | Name of the action. If not specified, the name of the operation will be used. |
@actionSeparator
Section titled “@actionSeparator”Defines the separator string that is inserted before the action name in auto-generated routes for actions.
@TypeSpec.Rest.actionSeparator(seperator: valueof "/" | ":" | "/:")
Target
Section titled “Target”Model | ModelProperty | Operation
Parameters
Section titled “Parameters”Name | Type | Description |
---|---|---|
seperator | valueof "/" | ":" | "/:" | Seperator seperating the action segment from the rest of the url |
@autoRoute
Section titled “@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
Section titled “Target”Interface | Operation
Parameters
Section titled “Parameters”None
Examples
Section titled “Examples”@autoRouteinterface Pets { get(@segment("pets") @path id: string): void; //-> route: /pets/{id}}
@collectionAction
Section titled “@collectionAction”Specify this operation is a collection action. (Scopped to a resource, /pets/my-action)
@TypeSpec.Rest.collectionAction(resourceType: Model, name?: valueof string)
Target
Section titled “Target”Operation
Parameters
Section titled “Parameters”Name | Type | Description |
---|---|---|
resourceType | Model | Resource marked with |
name | valueof string | Name of the action. If not specified, the name of the operation will be used. |
@copyResourceKeyParameters
Section titled “@copyResourceKeyParameters”Copy the resource key parameters on the model
@TypeSpec.Rest.copyResourceKeyParameters(filter?: valueof string)
Target
Section titled “Target”Model
Parameters
Section titled “Parameters”Name | Type | Description |
---|---|---|
filter | valueof string | Filter to exclude certain properties. |
@createsOrReplacesResource
Section titled “@createsOrReplacesResource”Specify that this is a CreateOrReplace operation for a given resource.
@TypeSpec.Rest.createsOrReplacesResource(resourceType: Model)
Target
Section titled “Target”Operation
Parameters
Section titled “Parameters”Name | Type | Description |
---|---|---|
resourceType | Model | Resource marked with |
@createsOrUpdatesResource
Section titled “@createsOrUpdatesResource”Specify that this is a CreatesOrUpdate operation for a given resource.
@TypeSpec.Rest.createsOrUpdatesResource(resourceType: Model)
Target
Section titled “Target”Operation
Parameters
Section titled “Parameters”Name | Type | Description |
---|---|---|
resourceType | Model | Resource marked with |
@createsResource
Section titled “@createsResource”Specify that this is a Create operation for a given resource.
@TypeSpec.Rest.createsResource(resourceType: Model)
Target
Section titled “Target”Operation
Parameters
Section titled “Parameters”Name | Type | Description |
---|---|---|
resourceType | Model | Resource marked with |
@deletesResource
Section titled “@deletesResource”Specify that this is a Delete operation for a given resource.
@TypeSpec.Rest.deletesResource(resourceType: Model)
Target
Section titled “Target”Operation
Parameters
Section titled “Parameters”Name | Type | Description |
---|---|---|
resourceType | Model | Resource marked with |
@listsResource
Section titled “@listsResource”Specify that this is a List operation for a given resource.
@TypeSpec.Rest.listsResource(resourceType: Model)
Target
Section titled “Target”Operation
Parameters
Section titled “Parameters”Name | Type | Description |
---|---|---|
resourceType | Model | Resource marked with |
@parentResource
Section titled “@parentResource”Mark model as a child of the given parent resource.
@TypeSpec.Rest.parentResource(parent: Model)
Target
Section titled “Target”Model
Parameters
Section titled “Parameters”Name | Type | Description |
---|---|---|
parent | Model | Parent model. |
@readsResource
Section titled “@readsResource”Specify that this is a Read operation for a given resource.
@TypeSpec.Rest.readsResource(resourceType: Model)
Target
Section titled “Target”Operation
Parameters
Section titled “Parameters”Name | Type | Description |
---|---|---|
resourceType | Model | Resource marked with |
@resource
Section titled “@resource”Mark this model as a resource type with a name.
@TypeSpec.Rest.resource(collectionName: valueof string)
Target
Section titled “Target”Model
Parameters
Section titled “Parameters”Name | Type | Description |
---|---|---|
collectionName | valueof string | type’s collection name |
@segment
Section titled “@segment”Defines the preceding path segment for a
@TypeSpec.Rest.segment(name: valueof string)
Target
Section titled “Target”Model | ModelProperty | Operation
Parameters
Section titled “Parameters”Name | Type | Description |
---|---|---|
name | valueof string | Segment that will be inserted into the operation route before the path parameter’s name field. |
Examples
Section titled “Examples”@segmentOf
Section titled “@segmentOf”Returns the URL segment of a given model if it has @segment
and @key
decorator.
@TypeSpec.Rest.segmentOf(type: Model)
Target
Section titled “Target”Operation
Parameters
Section titled “Parameters”Name | Type | Description |
---|---|---|
type | Model | Target model |
@updatesResource
Section titled “@updatesResource”Specify that this is a Update operation for a given resource.
@TypeSpec.Rest.updatesResource(resourceType: Model)
Target
Section titled “Target”Operation
Parameters
Section titled “Parameters”Name | Type | Description |
---|---|---|
resourceType | Model | Resource marked with |