ApiResponse overview
HTTP response declaration.
Added in v1.0.0
Table of contents
constructors
make
Signature
export declare const make: <S extends number, B = ApiSchema.Ignored, H = ApiSchema.Ignored, R = never>(
status: S,
body?: ApiSchema.Ignored | Schema.Schema<B, any, R> | undefined,
headers?: ApiSchema.Ignored | Schema.Schema<H, any, R> | undefined,
representations?: Array.NonEmptyReadonlyArray<Representation.Representation>
) => ApiResponse<S, B, H, R>
Added in v1.0.0
getters
getBodySchema
Signature
export declare const getBodySchema: <S extends number, B, H, R>(
response: ApiResponse<S, B, H, R>
) => ApiSchema.Ignored | Schema.Schema<B, any, R>
Added in v1.0.0
getHeadersSchema
Signature
export declare const getHeadersSchema: <S extends number, B, H, R>(
response: ApiResponse<S, B, H, R>
) => ApiSchema.Ignored | Schema.Schema<H, any, R>
Added in v1.0.0
getRepresentations
Signature
export declare const getRepresentations: <S extends number, B, H, R>(
response: ApiResponse<S, B, H, R>
) => readonly [Representation.Representation, ...Representation.Representation[]]
Added in v1.0.0
getStatus
Signature
export declare const getStatus: <S extends number, B, H, R>(response: ApiResponse<S, B, H, R>) => S
Added in v1.0.0
models
ApiResponse (interface)
Signature
export interface ApiResponse<S extends ApiResponse.AnyStatus, B, H, R>
extends ApiResponse.Variance<S, B, H, R>,
Pipeable.Pipeable {}
Added in v1.0.0
ApiResponse (namespace)
Added in v1.0.0
Variance (interface)
Signature
export interface Variance<S, B, H, R> {
readonly [TypeId]: {
readonly _S: Types.Covariant<S>
readonly _B: Types.Invariant<B>
readonly _H: Types.Invariant<H>
readonly _R: Types.Covariant<R>
}
}
Added in v1.0.0
Any (type alias)
Any request with all Body
, Path
, Query
and Headers
set to Schema.Schema.Any
.
Signature
export type Any = ApiResponse<AnyStatus, any, any, unknown>
Added in v1.0.0
AnyStatus (type alias)
Signature
export type AnyStatus = number
Added in v1.0.0
Body (type alias)
Signature
export type Body<Request> = [Request] extends [ApiResponse<any, infer B, any, any>] ? B : never
Added in v1.0.0
Context (type alias)
Signature
export type Context<Request> = [Request] extends [ApiResponse<any, any, any, infer R>] ? R : never
Added in v1.0.0
Default (type alias)
Default response.
Signature
export type Default = ApiResponse<200, ApiSchema.Ignored, ApiSchema.Ignored, never>
Added in v1.0.0
Headers (type alias)
Signature
export type Headers<Request> = [Request] extends [ApiResponse<any, any, infer H, any>] ? H : never
Added in v1.0.0
Status (type alias)
Signature
export type Status<Request> = [Request] extends [ApiResponse<infer S, any, any, any>] ? S : never
Added in v1.0.0
modifications
setBody
Signature
export declare const setBody: <B, R2>(
schema: Schema.Schema<B, any, R2>
) => <S extends number, _, H, R1>(response: ApiResponse<S, _, H, R1>) => ApiResponse<S, B, H, R2 | R1>
Added in v1.0.0
setHeaders
Signature
export declare const setHeaders: <H, R2>(
schema: Schema.Schema<H, any, R2>
) => <S extends number, B, _, R1>(response: ApiResponse<S, B, _, R1>) => ApiResponse<S, B, H, R2 | R1>
Added in v1.0.0
setRepresentations
Signature
export declare const setRepresentations: (
representations: readonly [Representation.Representation, ...Representation.Representation[]]
) => <S extends number, B, H, R>(response: ApiResponse<S, B, H, R>) => ApiResponse<S, B, H, R>
Added in v1.0.0
setStatus
Signature
export declare const setStatus: <S extends number>(
schema: S
) => <_ extends number, B, H, R>(response: ApiResponse<_, B, H, R>) => ApiResponse<S, B, H, R>
Added in v1.0.0
refinements
isApiResponse
Signature
export declare const isApiResponse: <S extends number = number, B = any, H = any, R = never>(
u: unknown
) => u is ApiResponse<S, B, H, R>
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