Api overview
HTTP API service declaration.
Added in v1.0.0
Table of contents
combining
addEndpoint
Signature
export declare const addEndpoint: <E2 extends ApiEndpoint.ApiEndpoint.Any>(
endpoint: E2
) => <E1 extends ApiEndpoint.ApiEndpoint.Any>(api: Api<E1>) => Api<E1 | E2>
Added in v1.0.0
addGroup
Signature
export declare const addGroup: <E2 extends ApiEndpoint.ApiEndpoint.Any>(
group: ApiGroup.ApiGroup<E2>
) => <E1 extends ApiEndpoint.ApiEndpoint.Any>(api: Api<E1>) => Api<E1 | E2>
Added in v1.0.0
setOptions
Signature
export declare const setOptions: (
options: Partial<Options>
) => <A extends ApiEndpoint.ApiEndpoint.Any>(self: Api<A>) => Api<A>
Added in v1.0.0
constructors
delete
Signature
export declare const delete: <Id extends ApiEndpoint.ApiEndpoint.AnyId>(id: Id, path: PathInput, options?: Partial<ApiEndpoint.Options>) => ApiEndpoint.ApiEndpoint.Default<Id>
Added in v1.0.0
endpoint
Signature
export declare const endpoint: <Id extends ApiEndpoint.ApiEndpoint.AnyId>(
method: HttpMethod,
id: Id,
path: PathInput,
options?: Partial<ApiEndpoint.Options>
) => ApiEndpoint.ApiEndpoint.Default<Id>
Added in v1.0.0
get
Signature
export declare const get: <Id extends ApiEndpoint.ApiEndpoint.AnyId>(
id: Id,
path: PathInput,
options?: Partial<ApiEndpoint.Options>
) => ApiEndpoint.ApiEndpoint.Default<Id>
Added in v1.0.0
make
Signature
export declare const make: (options?: Partial<Options>) => Api.Empty
Added in v1.0.0
patch
Signature
export declare const patch: <Id extends ApiEndpoint.ApiEndpoint.AnyId>(
id: Id,
path: PathInput,
options?: Partial<ApiEndpoint.Options>
) => ApiEndpoint.ApiEndpoint.Default<Id>
Added in v1.0.0
post
Signature
export declare const post: <Id extends ApiEndpoint.ApiEndpoint.AnyId>(
id: Id,
path: PathInput,
options?: Partial<ApiEndpoint.Options>
) => ApiEndpoint.ApiEndpoint.Default<Id>
Added in v1.0.0
put
Signature
export declare const put: <Id extends ApiEndpoint.ApiEndpoint.AnyId>(
id: Id,
path: PathInput,
options?: Partial<ApiEndpoint.Options>
) => ApiEndpoint.ApiEndpoint.Default<Id>
Added in v1.0.0
setRequest
Signature
export declare const setRequest: <Request extends ApiRequest.Any>(
request: Request
) => <
Id extends ApiEndpoint.ApiEndpoint.AnyId,
_ extends ApiRequest.Any,
Response extends ApiResponse.Any,
Security extends Security.Any
>(
endpoint: ApiEndpoint.ApiEndpoint<Id, _, Response, Security>
) => ApiEndpoint.ApiEndpoint<Id, Request, Response, Security>
Added in v1.0.0
getters
getEndpoint
Signature
export declare const getEndpoint: <A extends Api.Any, Id extends Api.Ids<A>>(api: A, id: Id) => Api.EndpointById<A, Id>
Added in v1.0.0
models
Api (interface)
Signature
export interface Api<A extends ApiEndpoint.ApiEndpoint.Any> extends Pipeable.Pipeable, Api.Variance<A> {
readonly groups: ReadonlyArray<ApiGroup.ApiGroup<A>>
readonly options: Options
}
Added in v1.0.0
Api (namespace)
Added in v1.0.0
Variance (interface)
Signature
export interface Variance<A extends ApiEndpoint.ApiEndpoint.Any> {
readonly [TypeId]: {
readonly _A: Types.Covariant<A>
}
}
Added in v1.0.0
Any (type alias)
Any api with Endpoint = Endpoint.Any
Signature
export type Any = Api<ApiEndpoint.ApiEndpoint.Any>
Added in v1.0.0
Context (type alias)
Signature
export type Context<A> = [A] extends [Api<infer E>] ? ApiEndpoint.ApiEndpoint.Context<E> : never
Added in v1.0.0
Empty (type alias)
Default api spec.
Signature
export type Empty = Api<never>
Added in v1.0.0
EndpointById (type alias)
Signature
export type EndpointById<A extends Any, Id extends ApiEndpoint.ApiEndpoint.AnyId> = [A] extends [Api<infer E>]
? E extends ApiEndpoint.ApiEndpoint<Id, any, any, any>
? E
: never
: never
Added in v1.0.0
Endpoints (type alias)
Signature
export type Endpoints<A extends Any> = [A] extends [Api<infer E>] ? E : never
Added in v1.0.0
Ids (type alias)
Signature
export type Ids<A extends Any> = [Endpoints<A>] extends [ApiEndpoint.ApiEndpoint<infer Id, any, any, any>] ? Id : never
Added in v1.0.0
Options (interface)
Signature
export interface Options {
readonly title: string
readonly version: string
readonly description?: string
readonly servers?: ReadonlyArray<OpenApiTypes.OpenAPISpecServer | string>
readonly license?: {
readonly name: string
readonly url?: string
}
}
Added in v1.0.0
modifications
addResponse
Signature
export declare const addResponse: <
Status extends ApiResponse.AnyStatus,
Body = ApiSchema.Ignored,
Headers = ApiSchema.Ignored,
R = never
>(
response:
| ApiResponse<Status, Body, Headers, R>
| {
readonly status: Status
readonly body?: Schema.Schema<Body, any, R>
readonly headers?: Schema.Schema<Headers, any, R>
}
) => <
Id extends ApiEndpoint.ApiEndpoint.AnyId,
Request extends ApiRequest.Any,
Response1 extends ApiResponse.Any,
Security extends Security.Any
>(
endpoint: ApiEndpoint.ApiEndpoint<Id, Request, Response1, Security>
) => ApiEndpoint.ApiEndpoint<Id, Request, Response1 | ApiResponse<Status, Body, Headers, R>, Security>
Added in v1.0.0
setEndpointOptions
Signature
export declare const setEndpointOptions: (
options: Partial<ApiEndpoint.Options>
) => <A extends ApiEndpoint.ApiEndpoint.Any>(endpoint: A) => A
Added in v1.0.0
setRequestBody
Signature
export declare const setRequestBody: <B, R2>(
schema: Schema.Schema<B, any, R2>
) => <
Id extends ApiEndpoint.ApiEndpoint.AnyId,
_,
P,
Q,
H,
R1,
Response extends ApiResponse.Any,
Security extends Security.Any
>(
endpoint: ApiEndpoint.ApiEndpoint<Id, ApiRequest<_, P, Q, H, R1>, Response, Security>
) => ApiEndpoint.ApiEndpoint<Id, ApiRequest<B, P, Q, H, R1 | R2>, Response, Security>
Added in v1.0.0
setRequestHeaders
Signature
export declare const setRequestHeaders: <H, I extends Readonly<Record<string, string | undefined>>, R2>(
schema: Schema.Schema<H, I, R2>
) => <
Id extends ApiEndpoint.ApiEndpoint.AnyId,
B,
P,
Q,
_,
R1,
Response extends ApiResponse.Any,
Security extends Security.Any
>(
endpoint: ApiEndpoint.ApiEndpoint<Id, ApiRequest<B, P, Q, _, R1>, Response, Security>
) => ApiEndpoint.ApiEndpoint<Id, ApiRequest<B, P, Q, H, R1 | R2>, Response, Security>
Added in v1.0.0
setRequestPath
Signature
export declare const setRequestPath: <P, I extends Readonly<Record<string, string | undefined>>, R2>(
schema: Schema.Schema<P, I, R2>
) => <
Id extends ApiEndpoint.ApiEndpoint.AnyId,
B,
_,
Q,
H,
R1,
Response extends ApiResponse.Any,
Security extends Security.Any
>(
endpoint: ApiEndpoint.ApiEndpoint<Id, ApiRequest<B, _, Q, H, R1>, Response, Security>
) => ApiEndpoint.ApiEndpoint<Id, ApiRequest<B, P, Q, H, R1 | R2>, Response, Security>
Added in v1.0.0
setRequestQuery
Signature
export declare const setRequestQuery: <
Q,
I extends Readonly<Record<string, string | undefined | ReadonlyArray<string>>>,
R2
>(
schema: Schema.Schema<Q, I, R2>
) => <
Id extends ApiEndpoint.ApiEndpoint.AnyId,
B,
P,
_,
H,
R1,
Response extends ApiResponse.Any,
Security extends Security.Any
>(
endpoint: ApiEndpoint.ApiEndpoint<Id, ApiRequest<B, P, _, H, R1>, Response, Security>
) => ApiEndpoint.ApiEndpoint<Id, ApiRequest<B, P, Q, H, R1 | R2>, Response, Security>
Added in v1.0.0
setResponse
Signature
export declare const setResponse: <
Status extends ApiResponse.AnyStatus,
Body = ApiSchema.Ignored,
Headers = ApiSchema.Ignored,
R = never
>(
response:
| {
readonly status: Status
readonly body?: Schema.Schema<Body, any, R>
readonly headers?: Schema.Schema<Headers, any, R>
}
| ApiResponse<Status, Body, Headers, R>
) => <
Id extends ApiEndpoint.ApiEndpoint.AnyId,
Request extends ApiRequest.Any,
_ extends ApiResponse.Any,
Security extends Security.Any
>(
endpoint: ApiEndpoint.ApiEndpoint<Id, Request, _, Security>
) => ApiEndpoint.ApiEndpoint<Id, Request, ApiResponse<Status, Body, Headers, R>, Security>
Added in v1.0.0
setResponseBody
Signature
export declare const setResponseBody: <B, R2>(
schema: Schema.Schema<B, any, R2>
) => <
Id extends ApiEndpoint.ApiEndpoint.AnyId,
Request extends ApiRequest.Any,
S extends ApiResponse.AnyStatus,
_,
H,
R1,
Security extends Security.Any
>(
endpoint: ApiEndpoint.ApiEndpoint<Id, Request, ApiResponse<S, _, H, R1>, Security>
) => ApiEndpoint.ApiEndpoint<Id, Request, ApiResponse<S, B, H, R1 | R2>, Security>
Added in v1.0.0
setResponseHeaders
Signature
export declare const setResponseHeaders: <H, R2>(
schema: Schema.Schema<H, any, R2>
) => <
Id extends ApiEndpoint.ApiEndpoint.AnyId,
Request extends ApiRequest.Any,
S extends ApiResponse.AnyStatus,
B,
_,
R1,
Security extends Security.Any
>(
endpoint: ApiEndpoint.ApiEndpoint<Id, Request, ApiResponse<S, B, _, R1>, Security>
) => ApiEndpoint.ApiEndpoint<Id, Request, ApiResponse<S, B, H, R1 | R2>, Security>
Added in v1.0.0
setResponseRepresentations
Signature
export declare const setResponseRepresentations: (
representations: NonEmptyReadonlyArray<Representation>
) => <
Id extends ApiEndpoint.ApiEndpoint.AnyId,
Request extends ApiRequest.Any,
Response extends ApiResponse.Any,
Security extends Security.Any
>(
endpoint: ApiEndpoint.ApiEndpoint<Id, Request, Response, Security>
) => ApiEndpoint.ApiEndpoint<Id, Request, Response, Security>
Added in v1.0.0
setResponseStatus
Signature
export declare const setResponseStatus: <Status extends ApiResponse.AnyStatus>(
status: Status
) => <
Id extends ApiEndpoint.ApiEndpoint.AnyId,
Request extends ApiRequest.Any,
_ extends ApiResponse.AnyStatus,
B,
H,
R,
Security extends Security.Any
>(
endpoint: ApiEndpoint.ApiEndpoint<Id, Request, ApiResponse<_, B, H, R>, Security>
) => ApiEndpoint.ApiEndpoint<Id, Request, ApiResponse<Status, B, H, R>, Security>
Added in v1.0.0
setSecurity
Signature
export declare const setSecurity: <Security extends Security.Any>(
security: Security
) => <
Id extends ApiEndpoint.ApiEndpoint.AnyId,
Request extends ApiRequest.Any,
Response extends ApiResponse.Any,
_ extends Security.Any
>(
endpoint: ApiEndpoint.ApiEndpoint<Id, Request, Response, _>
) => ApiEndpoint.ApiEndpoint<Id, Request, Response, Security>
Added in v1.0.0
refinements
isApi
Signature
export declare const isApi: (u: unknown) => u is Api.Any
Added in v1.0.0
schemas
FormData
FormData schema
Signature
export declare const FormData: Schema.Schema<FormData, FormData, never>
Added in v1.0.0
type id
TypeId
Signature
export declare const TypeId: typeof TypeId
Added in v1.0.0
TypeId (type alias)
Signature
export type TypeId = typeof TypeId
Added in v1.0.0