@@ -67,11 +67,16 @@ export type OperationRequestBodyContent<T> = FilterKeys<
6767 | undefined
6868 : FilterKeys < OperationRequestBodyMediaContent < T > , MediaType > ;
6969/** Return first 2XX response from a Response Object Map */
70- export type SuccessResponse < T > = FilterKeys < FilterKeys < T , OkStatus > , "content" > ;
70+ export type SuccessResponse < T > = ResponseContent < FilterKeys < T , OkStatus > > ;
7171/** Return first 5XX or 4XX response (in that order) from a Response Object Map */
72- export type ErrorResponse < T > = FilterKeys <
73- FilterKeys < T , ErrorStatus > ,
74- "content"
72+ export type ErrorResponse < T > = ResponseContent < FilterKeys < T , ErrorStatus > > ;
73+ /** Return first JSON-like 2XX response from a path + HTTP method */
74+ export type SuccessResponseJSON < PathMethod > = JSONLike <
75+ SuccessResponse < ResponseObjectMap < PathMethod > >
76+ > ;
77+ /** Return first JSON-like 5XX or 4XX response from a path + HTTP method */
78+ export type ErrorResponseJSON < PathMethod > = JSONLike <
79+ ErrorResponse < ResponseObjectMap < PathMethod > >
7580> ;
7681
7782// Generic TS utils
@@ -82,6 +87,8 @@ export type FilterKeys<Obj, Matchers> = {
8287} [ keyof Obj ] ;
8388/** Return any `[string]/[string]` media type (important because openapi-fetch allows any content response, not just JSON-like) */
8489export type MediaType = `${string } /${string } `;
90+ /** Return any media type containing "json" (works for "application/json", "application/vnd.api+json", "application/vnd.oai.openapi+json") */
91+ export type JSONLike < T > = FilterKeys < T , `${string } /json`> ;
8592/** Filter objects that have required keys */
8693export type FindRequiredKeys < T , K extends keyof T > = K extends unknown
8794 ? undefined extends T [ K ]
0 commit comments