cadl/packages/rest
Timothee Guerin 0dea649cd7
Update dependencies to resolve vulnerabilities and license issue (#3081)
- Remove unused rollup-plugin-dts dep that had problematic license
- Update dependencies to fix vulnerabilies
2024-03-29 21:22:06 +00:00
..
generated-defs Generate TypeScript decorator signatures from `extern dec` (#2122) 2024-03-19 23:08:59 +00:00
lib Generate TypeScript decorator signatures from `extern dec` (#2122) 2024-03-19 23:08:59 +00:00
src Generate TypeScript decorator signatures from `extern dec` (#2122) 2024-03-19 23:08:59 +00:00
test Improved ref docs for model (#2951) 2024-02-29 07:21:13 -08:00
.eslintrc.cjs Vitest improvements: vitest-ui, watch mode for deps, debug config (#2791) 2024-01-22 09:56:55 -08:00
CHANGELOG.json Prepare Publish for January Release (#2816) 2024-01-24 11:14:23 -08:00
CHANGELOG.md Remove old message burried in changelog (#2989) 2024-03-05 16:05:57 -08:00
LICENSE Rename packages in preparation for OSS release (#714) 2021-08-12 08:38:20 -05:00
README.md Improved ref docs for model (#2951) 2024-02-29 07:21:13 -08:00
package.json Update dependencies to resolve vulnerabilities and license issue (#3081) 2024-03-29 21:22:06 +00:00
tsconfig.config.json Vitest improvements: vitest-ui, watch mode for deps, debug config (#2791) 2024-01-22 09:56:55 -08:00
tsconfig.json Generate TypeScript decorator signatures from `extern dec` (#2122) 2024-03-19 23:08:59 +00:00
vitest.config.ts Vitest improvements: vitest-ui, watch mode for deps, debug config (#2791) 2024-01-22 09:56:55 -08:00

README.md

@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
Name Type Description
name valueof string Name 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
Name Type Description
seperator valueof "/" | ":" | "/:" 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
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

Copy the resource key parameters on the model

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

Model

Parameters
Name Type Description
filter valueof string Filter to exclude certain properties.

@createsOrReplacesResource

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

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

Operation

Parameters
Name Type Description
resourceType Model Resource marked with

@createsOrUpdatesResource

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

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

Operation

Parameters
Name Type Description
resourceType Model Resource marked with

@createsResource

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

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

Operation

Parameters
Name Type Description
resourceType Model Resource marked with

@deletesResource

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

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

Operation

Parameters
Name Type Description
resourceType Model Resource marked with

@listsResource

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

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

Operation

Parameters
Name Type Description
resourceType Model Resource marked with

@parentResource

Mark model as a child of the given parent resource.

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

Model

Parameters
Name Type Description
parent Model Parent model.

@readsResource

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

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

Operation

Parameters
Name Type Description
resourceType Model Resource marked with

@resource

Mark this model as a resource type with a name.

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

Model

Parameters
Name Type Description
collectionName valueof string type's collection name

@segment

Defines the preceding path segment for a

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

Model | ModelProperty | Operation

Parameters
Name Type Description
name valueof string Segment 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
Name Type Description
type Model Target model

@updatesResource

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

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

Operation

Parameters
Name Type Description
resourceType Model Resource marked with