@vrplatform/api 1.3.1-1368 → 1.3.1-1419

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/types.ts CHANGED
@@ -43,27 +43,27 @@ type RequestBodyCombinations = {
43
43
  [Path in keyof paths]: {
44
44
  [Method in keyof paths[Path]]: paths[Path][Method] extends never
45
45
  ? never
46
- : paths[Path][Method] extends {
47
- requestBody: {
48
- content: { 'application/json': unknown };
49
- };
50
- }
51
- ? `${Method & string}:${Path}`
52
- : never;
46
+ : ExtractJsonRequestBody<paths[Path][Method]> extends never
47
+ ? never
48
+ : `${Method & string}:${Path}`;
53
49
  }[keyof paths[Path]];
54
50
  }[keyof paths];
55
51
 
52
+ type ExtractJsonRequestBody<T> = T extends {
53
+ requestBody?: infer RequestBody;
54
+ }
55
+ ? RequestBody extends {
56
+ content: { 'application/json': infer Data };
57
+ }
58
+ ? Data
59
+ : never
60
+ : never;
61
+
56
62
  export type RequestBody<T extends RequestBodyCombinations> =
57
63
  T extends `${infer Method}:${infer Path}`
58
64
  ? Path extends keyof paths
59
65
  ? Method extends keyof paths[Path]
60
- ? paths[Path][Method] extends {
61
- requestBody: {
62
- content: { 'application/json': infer Data };
63
- };
64
- }
65
- ? Data
66
- : never
66
+ ? ExtractJsonRequestBody<paths[Path][Method]>
67
67
  : never
68
68
  : never
69
69
  : never;