Newly Paranoid Maintainers

    TypeScript icon, indicating that this package has built-in type declarations

    0.14.0 • Public • Published

    Cadl Rest Library

    This package provides Cadl decorators to describe REST API.


    In your cadl project root

    npm install @cadl-lang/rest


    See Rest section in the tutorial


    The @cadl-lang/rest library defines the following decorators:




    @parentResource marks a model property with a reference to its parent resource type

    The first argument should be a reference to a model type which will be treated as the parent type of the target model type. This will cause the @key properties of all parent types of the target type to show up in operations of the Resource*<T> interfaces defined in this library.

    @parentResource can only be applied to models.




    @segment defines the preceding path segment for a @path parameter in auto-generated routes

    The first argument should be a string that will be inserted into the operation route before the path parameter's name field. For example:

    op getUser(
      userId: string
    ): User

    Would produce the route /users/{userId}.

    @segment can only be applied to model properties or operation parameters.




    @route defines the relative route URI for the target operation

    The first argument should be a URI fragment that may contain one or more path parameter fields. If the namespace or interface that contains the operation is also marked with a @route decorator, it will be used as a prefix to the route URI of the operation.

    @route can only be applied to operations, namespaces, and interfaces.




    @autoRoute enables automatic route generation for an operation, namespace, or interface.

    When applied to an operation, it automatically generates the operation's route based on path parameter metadata. When applied to a namespace or interface, it causes all operations under that scope to have auto-generated routes.

    See also



    npm i @cadl-lang/rest@0.14.0





    Unpacked Size

    144 kB

    Total Files


    Last publish


    • azure-sdk