openapi-typescript-helpers
Advanced tools
Comparing version 0.0.11 to 0.0.12
@@ -100,7 +100,13 @@ // HTTP types | ||
/** Return `requestBody` for an Operation Object */ | ||
export type OperationRequestBody<T> = T extends { requestBody?: any } ? T["requestBody"] : never; | ||
/** Return type of `requestBody` for an Operation Object */ | ||
export type OperationRequestBody<T> = "requestBody" extends keyof T ? T["requestBody"] : never; | ||
/** Internal helper to get object type with only the `requestBody` property */ | ||
type PickRequestBody<T> = "requestBody" extends keyof T ? Pick<T, "requestBody"> : never; | ||
/** Resolve to `true` if request body is optional, else `false` */ | ||
export type IsOperationRequestBodyOptional<T> = RequiredKeysOf<PickRequestBody<T>> extends never ? true : false; | ||
/** Internal helper used in OperationRequestBodyContent */ | ||
export type OperationRequestBodyMediaContent<T> = undefined extends OperationRequestBody<T> | ||
export type OperationRequestBodyMediaContent<T> = IsOperationRequestBodyOptional<T> extends true | ||
? ResponseContent<NonNullable<OperationRequestBody<T>>> | undefined | ||
@@ -156,5 +162,20 @@ : ResponseContent<OperationRequestBody<T>>; | ||
export type JSONLike<T> = FilterKeys<T, `${string}/json`>; | ||
/** Filter objects that have required keys */ | ||
/** | ||
* Filter objects that have required keys | ||
* @deprecated Use `RequiredKeysOf` instead | ||
*/ | ||
export type FindRequiredKeys<T, K extends keyof T> = K extends unknown ? (undefined extends T[K] ? never : K) : K; | ||
/** Does this object contain required keys? */ | ||
/** | ||
* Does this object contain required keys? | ||
* @deprecated Use `RequiredKeysOf` instead | ||
*/ | ||
export type HasRequiredKeys<T> = FindRequiredKeys<T, keyof T>; | ||
/** Helper to get the required keys of an object. If no keys are required, will be `undefined` with strictNullChecks enabled, else `never` */ | ||
type RequiredKeysOfHelper<T> = { | ||
// biome-ignore lint/complexity/noBannedTypes: `{}` is necessary here | ||
[K in keyof T]: {} extends Pick<T, K> ? never : K; | ||
}[keyof T]; | ||
/** Get the required keys of an object, or `never` if no keys are required */ | ||
export type RequiredKeysOf<T> = RequiredKeysOfHelper<T> extends undefined ? never : RequiredKeysOfHelper<T>; |
{ | ||
"name": "openapi-typescript-helpers", | ||
"description": "TypeScript helpers for consuming openapi-typescript types", | ||
"version": "0.0.11", | ||
"version": "0.0.12", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Drew Powers", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17786
163