UNPKG

@elliots/openapi-ts-backend

Version:

Enables easy implementions of OpenAPI REST APIs in TypeScript with full typings of schemas and operations.

5 lines 2.5 kB
export declare const utils = "\n/**\n * Get property K in T if it exists, otherwise D.\n */\nexport type Property<T, K extends keyof any, D = unknown> = (K extends keyof T ? T[K] : D);\n\n/**\n * Like keyof but values. Get all values of T if it is an object, otherwise D.\n */\nexport type ValueOf<T, D = never> = T extends Record<string, unknown> ? T[keyof T] : D;\n\nexport type EmptyObject = Record<never, never>;\n"; export declare const requests = "\nimport {Params, Request, Response} from '@openapi-ts/request-types';\nimport {operations} from './spec';\nimport {EmptyObject, Property, ValueOf} from './utils';\n\nexport type RequestBody<OperationId extends keyof operations> =\n operations[OperationId] extends {requestBody: Record<string, any>} ?\n ValueOf<operations[OperationId]['requestBody']['content'], void> :\n void;\n\nexport type RequestPathParams<OperationId extends keyof operations> =\n Property<Property<operations[OperationId], 'parameters', EmptyObject>, 'path', EmptyObject>;\n\nexport type RequestQuery<OperationId extends keyof operations> =\n Property<Property<operations[OperationId], 'parameters', EmptyObject>, 'query', EmptyObject>;\n\nexport type RequestHeaders<OperationId extends keyof operations> =\n Property<Property<operations[OperationId], 'parameters', EmptyObject>, 'header', EmptyObject>;\n\nexport type ResponseBody<OperationId extends keyof operations> =\n ValueOf<Property<ValueOf<Property<operations[OperationId], 'responses', EmptyObject>>, 'content'>, void>;\n\nexport type ResponseHeaders<OperationId extends keyof operations> =\n Property<ValueOf<Property<operations[OperationId], 'responses', EmptyObject>>, 'headers'>;\n\nexport type OperationRequest<OperationId extends keyof operations> = Request<\n RequestBody<OperationId>,\n Params & RequestPathParams<OperationId>,\n Params & RequestQuery<OperationId>,\n Params & RequestHeaders<OperationId>>;\n\nexport type OperationResponse<OperationId extends keyof operations> = Response<\n ResponseBody<OperationId>,\n Params & ResponseHeaders<OperationId>>;\n"; export declare const handlers: string; export declare const index = "\nimport {components, operations} from './spec';\nimport {EmptyObject, Property} from './utils';\n\nexport type Schemas = Property<components, 'schemas', EmptyObject>;\nexport type Responses = Property<components, 'responses', EmptyObject>;\nexport type Operations = operations;\n\n"; //# sourceMappingURL=templates.d.ts.map