@mittwald/api-client-commons 3.1.0 → 4.0.1

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.
@@ -13,11 +13,7 @@ class Request {
13
13
  }
14
14
  buildAxiosConfig() {
15
15
  const { method, path } = this.operationDescriptor;
16
- const pathParameters = this.config &&
17
- "pathParameters" in this.config &&
18
- this.config.pathParameters !== null
19
- ? this.config.pathParameters
20
- : undefined;
16
+ const pathParameters = this.config;
21
17
  const openApiPath = new OpenAPIPath_js_1.default(path, pathParameters);
22
18
  const url = openApiPath.buildUrl();
23
19
  const data = this.config && "data" in this.config ? this.config.data : undefined;
@@ -1,6 +1,9 @@
1
1
  import { InferredRequestType, InferredResponseType, OpenAPIOperation } from "./OpenAPIOperation.js";
2
2
  import { NullableOnNoRequiredKeysDeep } from "./NullableOnNoRequiredKeysDeep.js";
3
- export type RequestConfig<TOp extends OpenAPIOperation> = NullableOnNoRequiredKeysDeep<InferredRequestType<TOp>>;
3
+ type UnboxPathParameters<T> = T extends {
4
+ pathParameters: infer TPath;
5
+ } ? Omit<T, "pathParameters"> & TPath : T;
6
+ export type RequestConfig<TOp extends OpenAPIOperation> = NullableOnNoRequiredKeysDeep<UnboxPathParameters<InferredRequestType<TOp>>>;
4
7
  export type ResponsePromise<TOp extends OpenAPIOperation> = Promise<InferredResponseType<TOp>>;
5
8
  type RequestFunctionWithOptionalRequest<TOp extends OpenAPIOperation> = (request?: RequestConfig<TOp>) => ResponsePromise<TOp>;
6
9
  type RequestFunctionWithRequiredRequest<TOp extends OpenAPIOperation> = (request: RequestConfig<TOp>) => ResponsePromise<TOp>;
@@ -20,3 +20,11 @@ function ignoredTestOptionalHeadersRequestTypes() {
20
20
  headers: { extra: true },
21
21
  });
22
22
  }
23
+ function ignoredTestPathParametersAreInRootOfRequestConfig() {
24
+ const f = {};
25
+ void f({
26
+ foo: "",
27
+ });
28
+ // @ts-expect-error Missing parameter
29
+ void f({});
30
+ }
@@ -13,11 +13,7 @@ export class Request {
13
13
  }
14
14
  buildAxiosConfig() {
15
15
  const { method, path } = this.operationDescriptor;
16
- const pathParameters = this.config &&
17
- "pathParameters" in this.config &&
18
- this.config.pathParameters !== null
19
- ? this.config.pathParameters
20
- : undefined;
16
+ const pathParameters = this.config;
21
17
  const openApiPath = new OpenAPIPath(path, pathParameters);
22
18
  const url = openApiPath.buildUrl();
23
19
  const data = this.config && "data" in this.config ? this.config.data : undefined;
@@ -1,6 +1,9 @@
1
1
  import { InferredRequestType, InferredResponseType, OpenAPIOperation } from "./OpenAPIOperation.js";
2
2
  import { NullableOnNoRequiredKeysDeep } from "./NullableOnNoRequiredKeysDeep.js";
3
- export type RequestConfig<TOp extends OpenAPIOperation> = NullableOnNoRequiredKeysDeep<InferredRequestType<TOp>>;
3
+ type UnboxPathParameters<T> = T extends {
4
+ pathParameters: infer TPath;
5
+ } ? Omit<T, "pathParameters"> & TPath : T;
6
+ export type RequestConfig<TOp extends OpenAPIOperation> = NullableOnNoRequiredKeysDeep<UnboxPathParameters<InferredRequestType<TOp>>>;
4
7
  export type ResponsePromise<TOp extends OpenAPIOperation> = Promise<InferredResponseType<TOp>>;
5
8
  type RequestFunctionWithOptionalRequest<TOp extends OpenAPIOperation> = (request?: RequestConfig<TOp>) => ResponsePromise<TOp>;
6
9
  type RequestFunctionWithRequiredRequest<TOp extends OpenAPIOperation> = (request: RequestConfig<TOp>) => ResponsePromise<TOp>;
@@ -18,4 +18,12 @@ function ignoredTestOptionalHeadersRequestTypes() {
18
18
  headers: { extra: true },
19
19
  });
20
20
  }
21
+ function ignoredTestPathParametersAreInRootOfRequestConfig() {
22
+ const f = {};
23
+ void f({
24
+ foo: "",
25
+ });
26
+ // @ts-expect-error Missing parameter
27
+ void f({});
28
+ }
21
29
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mittwald/api-client-commons",
3
- "version": "3.1.0",
3
+ "version": "4.0.1",
4
4
  "description": "Common types and utilities for mittwald API clients",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/mittwald/api-client-js.git",