Interface HttpApi<ReqHeadersT, ReqParamsT, ReqQueryT, ReqBodyT, ResStatusT, ResHeadersT, ResBodyT, ErrResStatusT, ErrResHeadersT, ErrResBodyT>

An HTTP API description

interface HttpApi<ReqHeadersT, ReqParamsT, ReqQueryT, ReqBodyT, ResStatusT, ResHeadersT, ResBodyT, ErrResStatusT, ErrResHeadersT, ErrResBodyT> {
    cachePolicy?: CachePolicy | "dynamic";
    credentials?: HttpApiCredentialsSetting;
    deprecated?: string | boolean;
    description?: string;
    example?: string;
    isSafeToRetry?: boolean;
    isYaschemaApi: true;
    isYaschemaHttpApi: true;
    method: HttpMethod;
    name: string;
    requestType?: HttpRequestType;
    responseType?: HttpResponseType | "dynamic";
    routeType: string;
    schemas: HttpApiSchemas<ReqHeadersT, ReqParamsT, ReqQueryT, ReqBodyT, ResStatusT, ResHeadersT, ResBodyT, ErrResStatusT, ErrResHeadersT, ErrResBodyT>;
    url: string;
}

Type Parameters

Hierarchy (view full)

Properties

cachePolicy?: CachePolicy | "dynamic"

The statically known cache policy. Use "dynamic" if the policy is determine dynamically.

{ canCache: false }

Controls how browsers deal with credentials.

"omit"

deprecated?: string | boolean

If true or a string, use of this Api is deprecated and usage should be discontinued as soon as possible. A string value may be used to document why the deprecation occurred and/or preferred upgrade strategies and APIs.

description?: string

A description, which can be used by code generation tools to generate documentation

example?: string

An example, which can be used by code generation tools to generate documentation

isSafeToRetry?: boolean

If true, it's safe to retry this API any time.

false

isYaschemaApi
isYaschemaHttpApi
method: HttpMethod
name: string

A name that can be used to describe this API, when logging for example

requestType?: HttpRequestType

The type of request to make.

The responsibility for encoding requests is handled by separate packages, such as yaschema-api-fetcher, but generally, for "form-data", body fields will be encoded similarly to how query fields are sent. That is, one should generally use setAllowedSerializationForms on numbers and booleans, since primitives are encoded as strings and arrays will be sent using the [] suffixed field names. Unlike queries however, form data supports Files. express-yaschema-api-handler and yaschema-api-fetcher also support JSON-encoded form data fields, which are automatically prefixed with yaschema/json: (for encoding objects and nested arrays, for example).

"json"

responseType?: HttpResponseType | "dynamic"

The type of response that will be generated. Use "dynamic" if the response type will be determined dynamically.

"json"

routeType: string

The type of route, which will be used to select a URL base and is configurable using setUrlBaseForRouteType

url: string

The URL for accessing this API, which may be relative to a URL base configuring for the routeType. Use {…} syntax to mark parameters, as you might with Express.