@typespec/http-client-js 0.2.0-dev.1 → 0.2.0-dev.3
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/dist/src/components/client-context/client-context-declaration.d.ts.map +1 -1
- package/dist/src/components/client-context/client-context-declaration.js.map +1 -1
- package/dist/src/components/client-context/client-context-factory.d.ts.map +1 -1
- package/dist/src/components/client-context/client-context-factory.js +7 -4
- package/dist/src/components/client-context/client-context-factory.js.map +1 -1
- package/dist/src/components/client-context/client-context-options.d.ts.map +1 -1
- package/dist/src/components/client-context/client-context-options.js +13 -9
- package/dist/src/components/client-context/client-context-options.js.map +1 -1
- package/dist/src/components/client-context/client-context.d.ts.map +1 -1
- package/dist/src/components/client-context/client-context.js +7 -12
- package/dist/src/components/client-context/client-context.js.map +1 -1
- package/dist/src/components/client-context/parametrized-endpoint.d.ts +1 -1
- package/dist/src/components/client-context/parametrized-endpoint.d.ts.map +1 -1
- package/dist/src/components/client-context/parametrized-endpoint.js +22 -13
- package/dist/src/components/client-context/parametrized-endpoint.js.map +1 -1
- package/dist/src/components/client-directory.d.ts +2 -2
- package/dist/src/components/client-directory.d.ts.map +1 -1
- package/dist/src/components/client-directory.js +33 -21
- package/dist/src/components/client-directory.js.map +1 -1
- package/dist/src/components/client-operation.d.ts.map +1 -1
- package/dist/src/components/client-operation.js +6 -6
- package/dist/src/components/client-operation.js.map +1 -1
- package/dist/src/components/client.d.ts +1 -1
- package/dist/src/components/client.d.ts.map +1 -1
- package/dist/src/components/client.js +83 -64
- package/dist/src/components/client.js.map +1 -1
- package/dist/src/components/encoding-provider.d.ts.map +1 -1
- package/dist/src/components/encoding-provider.js +0 -1
- package/dist/src/components/encoding-provider.js.map +1 -1
- package/dist/src/components/http-request-options.d.ts.map +1 -1
- package/dist/src/components/http-request-options.js +3 -3
- package/dist/src/components/http-request-options.js.map +1 -1
- package/dist/src/components/http-request-parameters-expression.d.ts +1 -2
- package/dist/src/components/http-request-parameters-expression.d.ts.map +1 -1
- package/dist/src/components/http-request-parameters-expression.js +37 -33
- package/dist/src/components/http-request-parameters-expression.js.map +1 -1
- package/dist/src/components/http-request.d.ts.map +1 -1
- package/dist/src/components/http-request.js +24 -20
- package/dist/src/components/http-request.js.map +1 -1
- package/dist/src/components/http-response.d.ts +1 -1
- package/dist/src/components/http-response.d.ts.map +1 -1
- package/dist/src/components/http-response.js +36 -33
- package/dist/src/components/http-response.js.map +1 -1
- package/dist/src/components/models.d.ts.map +1 -1
- package/dist/src/components/models.js +21 -18
- package/dist/src/components/models.js.map +1 -1
- package/dist/src/components/operation-options.d.ts.map +1 -1
- package/dist/src/components/operation-options.js +17 -14
- package/dist/src/components/operation-options.js.map +1 -1
- package/dist/src/components/output.d.ts.map +1 -1
- package/dist/src/components/output.js +2 -1
- package/dist/src/components/output.js.map +1 -1
- package/dist/src/components/serializers.d.ts.map +1 -1
- package/dist/src/components/serializers.js +3 -3
- package/dist/src/components/serializers.js.map +1 -1
- package/dist/src/components/static-helpers/bytes-encoding.d.ts.map +1 -1
- package/dist/src/components/static-helpers/bytes-encoding.js +2 -2
- package/dist/src/components/static-helpers/bytes-encoding.js.map +1 -1
- package/dist/src/components/static-helpers/interfaces.d.ts.map +1 -1
- package/dist/src/components/static-helpers/interfaces.js.map +1 -1
- package/dist/src/components/static-helpers/multipart-helpers.d.ts.map +1 -1
- package/dist/src/components/static-helpers/multipart-helpers.js +4 -4
- package/dist/src/components/static-helpers/multipart-helpers.js.map +1 -1
- package/dist/src/components/static-helpers/rest-error.d.ts.map +1 -1
- package/dist/src/components/static-helpers/rest-error.js +66 -57
- package/dist/src/components/static-helpers/rest-error.js.map +1 -1
- package/dist/src/components/transforms/content-type-encoding-provider.d.ts.map +1 -1
- package/dist/src/components/transforms/content-type-encoding-provider.js +0 -1
- package/dist/src/components/transforms/content-type-encoding-provider.js.map +1 -1
- package/dist/src/components/transforms/json/json-array-transform.d.ts.map +1 -1
- package/dist/src/components/transforms/json/json-array-transform.js.map +1 -1
- package/dist/src/components/transforms/json/json-model-additional-properties-transform.d.ts.map +1 -1
- package/dist/src/components/transforms/json/json-model-additional-properties-transform.js +4 -4
- package/dist/src/components/transforms/json/json-model-additional-properties-transform.js.map +1 -1
- package/dist/src/components/transforms/json/json-model-base-transform.d.ts.map +1 -1
- package/dist/src/components/transforms/json/json-model-base-transform.js.map +1 -1
- package/dist/src/components/transforms/json/json-model-property-transform.d.ts.map +1 -1
- package/dist/src/components/transforms/json/json-model-property-transform.js.map +1 -1
- package/dist/src/components/transforms/json/json-model-transform.d.ts.map +1 -1
- package/dist/src/components/transforms/json/json-model-transform.js +20 -17
- package/dist/src/components/transforms/json/json-model-transform.js.map +1 -1
- package/dist/src/components/transforms/json/json-record-transform.d.ts.map +1 -1
- package/dist/src/components/transforms/json/json-record-transform.js.map +1 -1
- package/dist/src/components/transforms/json/json-transform-discriminator.d.ts.map +1 -1
- package/dist/src/components/transforms/json/json-transform-discriminator.js +3 -3
- package/dist/src/components/transforms/json/json-transform-discriminator.js.map +1 -1
- package/dist/src/components/transforms/json/json-transform.d.ts.map +1 -1
- package/dist/src/components/transforms/json/json-transform.js.map +1 -1
- package/dist/src/components/transforms/json/union-transform.d.ts.map +1 -1
- package/dist/src/components/transforms/json/union-transform.js +2 -2
- package/dist/src/components/transforms/json/union-transform.js.map +1 -1
- package/dist/src/components/transforms/multipart/array-part-transform.d.ts.map +1 -1
- package/dist/src/components/transforms/multipart/array-part-transform.js.map +1 -1
- package/dist/src/components/transforms/multipart/file-part-transform.js +1 -1
- package/dist/src/components/transforms/multipart/file-part-transform.js.map +1 -1
- package/dist/src/components/transforms/multipart/multipart-transform.d.ts.map +1 -1
- package/dist/src/components/transforms/multipart/multipart-transform.js +9 -6
- package/dist/src/components/transforms/multipart/multipart-transform.js.map +1 -1
- package/dist/src/components/transforms/multipart/simple-part-transform.d.ts.map +1 -1
- package/dist/src/components/transforms/multipart/simple-part-transform.js +1 -1
- package/dist/src/components/transforms/multipart/simple-part-transform.js.map +1 -1
- package/dist/src/components/transforms/operation-transform-declaration.d.ts.map +1 -1
- package/dist/src/components/transforms/operation-transform-declaration.js +2 -2
- package/dist/src/components/transforms/operation-transform-declaration.js.map +1 -1
- package/dist/src/components/transforms/operation-transform-expression.d.ts.map +1 -1
- package/dist/src/components/transforms/operation-transform-expression.js.map +1 -1
- package/dist/src/components/utils/url-template.d.ts.map +1 -1
- package/dist/src/components/utils/url-template.js.map +1 -1
- package/dist/src/emitter.d.ts.map +1 -1
- package/dist/src/emitter.js +6 -6
- package/dist/src/emitter.js.map +1 -1
- package/dist/src/utils/operations.d.ts +13 -1
- package/dist/src/utils/operations.d.ts.map +1 -1
- package/dist/src/utils/operations.js +71 -0
- package/dist/src/utils/operations.js.map +1 -1
- package/dist/src/utils/parameters.d.ts.map +1 -1
- package/dist/src/utils/parameters.js +1 -1
- package/dist/src/utils/parameters.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -12
- package/src/components/client-context/client-context-declaration.tsx +8 -1
- package/src/components/client-context/client-context-factory.tsx +50 -30
- package/src/components/client-context/client-context-options.tsx +13 -6
- package/src/components/client-context/client-context.tsx +5 -3
- package/src/components/client-context/parametrized-endpoint.tsx +26 -15
- package/src/components/client-directory.tsx +26 -16
- package/src/components/client-operation.tsx +24 -12
- package/src/components/client.tsx +77 -39
- package/src/components/encoding-provider.tsx +1 -3
- package/src/components/http-request-options.tsx +24 -14
- package/src/components/http-request-parameters-expression.tsx +34 -37
- package/src/components/http-request.tsx +26 -16
- package/src/components/http-response.tsx +31 -26
- package/src/components/models.tsx +18 -14
- package/src/components/operation-options.tsx +18 -5
- package/src/components/output.tsx +10 -9
- package/src/components/serializers.tsx +9 -5
- package/src/components/static-helpers/bytes-encoding.tsx +26 -8
- package/src/components/static-helpers/interfaces.tsx +14 -9
- package/src/components/static-helpers/multipart-helpers.tsx +34 -13
- package/src/components/static-helpers/rest-error.tsx +56 -18
- package/src/components/transforms/content-type-encoding-provider.tsx +1 -3
- package/src/components/transforms/json/json-array-transform.tsx +6 -4
- package/src/components/transforms/json/json-model-additional-properties-transform.tsx +18 -13
- package/src/components/transforms/json/json-model-base-transform.tsx +6 -1
- package/src/components/transforms/json/json-model-property-transform.tsx +7 -9
- package/src/components/transforms/json/json-model-transform.tsx +44 -16
- package/src/components/transforms/json/json-record-transform.tsx +5 -3
- package/src/components/transforms/json/json-transform-discriminator.tsx +12 -11
- package/src/components/transforms/json/json-transform.tsx +5 -3
- package/src/components/transforms/json/union-transform.tsx +20 -8
- package/src/components/transforms/multipart/array-part-transform.tsx +6 -3
- package/src/components/transforms/multipart/file-part-transform.tsx +1 -1
- package/src/components/transforms/multipart/multipart-transform.tsx +4 -6
- package/src/components/transforms/multipart/part-transform.tsx +1 -1
- package/src/components/transforms/multipart/simple-part-transform.tsx +7 -10
- package/src/components/transforms/operation-transform-declaration.tsx +24 -7
- package/src/components/transforms/operation-transform-expression.tsx +12 -5
- package/src/components/utils/url-template.tsx +10 -6
- package/src/emitter.tsx +4 -3
- package/src/utils/operations.ts +96 -1
- package/src/utils/parameters.tsx +5 -1
- package/test/scenarios/additional-properties/extends.md +0 -4
- package/test/scenarios/additional-properties/is.md +0 -4
- package/test/scenarios/additional-properties/spread.md +0 -4
- package/test/scenarios/auth/basic_auth.md +0 -1
- package/test/scenarios/auth/bearer.md +0 -1
- package/test/scenarios/auth/client_parameters.md +0 -1
- package/test/scenarios/auth/key_credential.md +0 -1
- package/test/scenarios/auth/sub_client_override.md +0 -2
- package/test/scenarios/client/dotted_namespace.md +0 -1
- package/test/scenarios/client/global_namespace.md +0 -5
- package/test/scenarios/client/multiple_top_level_clients.md +0 -2
- package/test/scenarios/client/nested_client.md +0 -2
- package/test/scenarios/encoding/bytes_body.md +0 -4
- package/test/scenarios/encoding/bytes_json_property.md +0 -5
- package/test/scenarios/encoding/bytes_nullable.md +0 -14
- package/test/scenarios/encoding/header_bytes.md +0 -12
- package/test/scenarios/encoding/header_date.md +0 -20
- package/test/scenarios/encoding/model_with_bytes_property.md +0 -5
- package/test/scenarios/encoding/query_bytes.md +0 -4
- package/test/scenarios/encoding/query_date.md +0 -20
- package/test/scenarios/http-operations/basic-request.md +0 -12
- package/test/scenarios/http-operations/basic-response.md +0 -19
- package/test/scenarios/http-operations/basic.md +0 -6
- package/test/scenarios/http-operations/constant-header.md +0 -4
- package/test/scenarios/http-operations/create-operation.md +0 -4
- package/test/scenarios/http-operations/on_response.md +0 -4
- package/test/scenarios/http-operations/optional-request-body.md +0 -5
- package/test/scenarios/http-operations/path-parameter-in-model.md +0 -4
- package/test/scenarios/http-operations/path-parameter.md +0 -4
- package/test/scenarios/http-operations/scalar-payload.md +0 -4
- package/test/scenarios/http-operations/with-parameters.md +0 -5
- package/test/scenarios/models/inheritance_2_discriminators.md +0 -24
- package/test/scenarios/models/inheritance_discriminator.md +0 -4
- package/test/scenarios/models/inline-models.md +1 -4
- package/test/scenarios/models/model_additional_properties.md +0 -4
- package/test/scenarios/models/model_extends.md +0 -4
- package/test/scenarios/models/model_spread.md +0 -2
- package/test/scenarios/models/nested_property.md +0 -4
- package/test/scenarios/models/property_references_property.md +0 -6
- package/test/scenarios/multipart/anonymous_part.md +1 -10
- package/test/scenarios/multipart/file.md +0 -12
- package/test/scenarios/multipart/file_content_type.md +0 -5
- package/test/scenarios/multipart/simple_part.md +0 -4
- package/test/scenarios/operation-parameters/body_root_anonymous.md +2 -17
- package/test/scenarios/operation-parameters/constant_as_optional.md +0 -5
- package/test/scenarios/operation-parameters/default_value_as_optional.md +0 -5
- package/test/scenarios/operation-parameters/no_content_type.md +0 -5
- package/test/scenarios/operation-parameters/no_parameters.md +0 -5
- package/test/scenarios/operation-parameters/only_optional.md +0 -5
- package/test/scenarios/operation-parameters/only_required.md +0 -5
- package/test/scenarios/operation-parameters/reserved_names.md +0 -5
- package/test/scenarios/operation-parameters/spread_body.md +0 -5
- package/test/scenarios/operation-parameters/spread_with_nested.md +0 -5
- package/test/scenarios/operation-parameters/union_body.md +0 -6
- package/test/scenarios/operation-parameters/with_body_property.md +0 -5
- package/test/scenarios/operation-parameters/with_body_root.md +0 -5
- package/test/scenarios/serializers/arrays.md +0 -8
- package/test/scenarios/serializers/basic_model.md +0 -4
- package/test/scenarios/serializers/basic_model_wire_name.md +0 -2
- package/test/scenarios/serializers/discriminated_union_spread.md +0 -4
- package/test/scenarios/serializers/multipart.md +0 -4
- package/test/scenarios/serializers/polymorphic_single_level_inheritance.md +0 -5
- package/test/scenarios/serializers/record.md +0 -4
- package/test/scenarios/serializers/scalars.md +0 -5
- package/test/scenarios/serializers/spread.md +0 -4
- package/test/scenarios/serializers/string_union.md +0 -4
package/src/utils/parameters.tsx
CHANGED
|
@@ -57,7 +57,11 @@ function buildClientParameterDescriptor(
|
|
|
57
57
|
{
|
|
58
58
|
refkey: ay.refkey(modelProperty),
|
|
59
59
|
optional: modelProperty.optional,
|
|
60
|
-
type: ay.mapJoin(
|
|
60
|
+
type: ay.mapJoin(
|
|
61
|
+
() => credentialType,
|
|
62
|
+
(t) => t,
|
|
63
|
+
{ joiner: " | " },
|
|
64
|
+
),
|
|
61
65
|
},
|
|
62
66
|
];
|
|
63
67
|
}
|
|
@@ -37,10 +37,8 @@ export function jsonWidgetToTransportTransform(input_?: Widget | null): any {
|
|
|
37
37
|
if (!input_) {
|
|
38
38
|
return input_ as any;
|
|
39
39
|
}
|
|
40
|
-
|
|
41
40
|
return {
|
|
42
41
|
...jsonRecordUnknownToTransportTransform(input_.additionalProperties),
|
|
43
|
-
|
|
44
42
|
name: input_.name,
|
|
45
43
|
age: input_.age,
|
|
46
44
|
optional: input_.optional,
|
|
@@ -57,12 +55,10 @@ export function jsonWidgetToApplicationTransform(input_?: any): Widget {
|
|
|
57
55
|
if (!input_) {
|
|
58
56
|
return input_ as any;
|
|
59
57
|
}
|
|
60
|
-
|
|
61
58
|
return {
|
|
62
59
|
additionalProperties: jsonRecordUnknownToApplicationTransform(
|
|
63
60
|
(({ name, age, optional, ...rest }) => rest)(input_),
|
|
64
61
|
),
|
|
65
|
-
|
|
66
62
|
name: input_.name,
|
|
67
63
|
age: input_.age,
|
|
68
64
|
optional: input_.optional,
|
|
@@ -26,21 +26,17 @@ export async function foo(
|
|
|
26
26
|
options?: FooOptions,
|
|
27
27
|
): Promise<Record<string, string>> {
|
|
28
28
|
const path = parse("/").expand({});
|
|
29
|
-
|
|
30
29
|
const httpRequestOptions = {
|
|
31
30
|
headers: {},
|
|
32
31
|
};
|
|
33
|
-
|
|
34
32
|
const response = await client.pathUnchecked(path).get(httpRequestOptions);
|
|
35
33
|
|
|
36
34
|
if (typeof options?.operationOptions?.onResponse === "function") {
|
|
37
35
|
options?.operationOptions?.onResponse(response);
|
|
38
36
|
}
|
|
39
|
-
|
|
40
37
|
if (+response.status === 200 && response.headers["content-type"]?.includes("application/json")) {
|
|
41
38
|
return jsonRecordStringToApplicationTransform(response.body)!;
|
|
42
39
|
}
|
|
43
|
-
|
|
44
40
|
throw createRestError(response);
|
|
45
41
|
}
|
|
46
42
|
```
|
|
@@ -38,10 +38,8 @@ export function jsonWidgetToTransportTransform(input_?: Widget | null): any {
|
|
|
38
38
|
if (!input_) {
|
|
39
39
|
return input_ as any;
|
|
40
40
|
}
|
|
41
|
-
|
|
42
41
|
return {
|
|
43
42
|
...jsonRecordStringToTransportTransform(input_.additionalProperties),
|
|
44
|
-
|
|
45
43
|
name: input_.name,
|
|
46
44
|
age: input_.age,
|
|
47
45
|
optional: input_.optional,
|
|
@@ -58,12 +56,10 @@ export function jsonWidgetToApplicationTransform(input_?: any): Widget {
|
|
|
58
56
|
if (!input_) {
|
|
59
57
|
return input_ as any;
|
|
60
58
|
}
|
|
61
|
-
|
|
62
59
|
return {
|
|
63
60
|
additionalProperties: jsonRecordStringToApplicationTransform(
|
|
64
61
|
(({ name, age, optional, ...rest }) => rest)(input_),
|
|
65
62
|
),
|
|
66
|
-
|
|
67
63
|
name: input_.name,
|
|
68
64
|
age: input_.age,
|
|
69
65
|
optional: input_.optional,
|
|
@@ -27,7 +27,6 @@ The client signature should include a positional parameter for credential of typ
|
|
|
27
27
|
```ts src/testClient.ts class TestClient
|
|
28
28
|
export class TestClient {
|
|
29
29
|
#context: TestClientContext;
|
|
30
|
-
|
|
31
30
|
constructor(endpoint: string, credential: KeyCredential, options?: TestClientOptions) {
|
|
32
31
|
this.#context = createTestClientContext(endpoint, credential, options);
|
|
33
32
|
}
|
|
@@ -27,7 +27,6 @@ The client signature should include a positional parameter for credential of typ
|
|
|
27
27
|
```ts src/testClient.ts class TestClient
|
|
28
28
|
export class TestClient {
|
|
29
29
|
#context: TestClientContext;
|
|
30
|
-
|
|
31
30
|
constructor(endpoint: string, credential: KeyCredential, options?: TestClientOptions) {
|
|
32
31
|
this.#context = createTestClientContext(endpoint, credential, options);
|
|
33
32
|
}
|
|
@@ -28,7 +28,6 @@ TODO: Revisit if we need additional types since it will be difficult at runtime
|
|
|
28
28
|
```ts src/testClient.ts class TestClient
|
|
29
29
|
export class TestClient {
|
|
30
30
|
#context: TestClientContext;
|
|
31
|
-
|
|
32
31
|
constructor(endpoint: string, credential: KeyCredential, options?: TestClientOptions) {
|
|
33
32
|
this.#context = createTestClientContext(endpoint, credential, options);
|
|
34
33
|
}
|
|
@@ -27,7 +27,6 @@ The client signature should include a positional parameter for credential of typ
|
|
|
27
27
|
```ts src/testClient.ts class TestClient
|
|
28
28
|
export class TestClient {
|
|
29
29
|
#context: TestClientContext;
|
|
30
|
-
|
|
31
30
|
constructor(endpoint: string, credential: KeyCredential, options?: TestClientOptions) {
|
|
32
31
|
this.#context = createTestClientContext(endpoint, credential, options);
|
|
33
32
|
}
|
|
@@ -36,7 +36,6 @@ The subclient is not a child of the TestClient because they have different param
|
|
|
36
36
|
```ts src/testClient.ts class TestClient
|
|
37
37
|
export class TestClient {
|
|
38
38
|
#context: TestClientContext;
|
|
39
|
-
|
|
40
39
|
constructor(endpoint: string, credential: KeyCredential, options?: TestClientOptions) {
|
|
41
40
|
this.#context = createTestClientContext(endpoint, credential, options);
|
|
42
41
|
}
|
|
@@ -51,7 +50,6 @@ The sub client shouldn't take a credential
|
|
|
51
50
|
```ts src/testClient.ts class SubClient
|
|
52
51
|
export class SubClient {
|
|
53
52
|
#context: SubClientContext;
|
|
54
|
-
|
|
55
53
|
constructor(endpoint: string, options?: SubClientOptions) {
|
|
56
54
|
this.#context = createSubClientContext(endpoint, options);
|
|
57
55
|
}
|
|
@@ -19,7 +19,6 @@ The client should match the last namespace.
|
|
|
19
19
|
```ts src/bazClient.ts class BazClient
|
|
20
20
|
export class BazClient {
|
|
21
21
|
#context: BazClientContext;
|
|
22
|
-
|
|
23
22
|
constructor(endpoint: string, options?: BazClientOptions) {
|
|
24
23
|
this.#context = createBazClientContext(endpoint, options);
|
|
25
24
|
}
|
|
@@ -39,7 +39,6 @@ It should generate a client for the Global Namespace with a single operation `fo
|
|
|
39
39
|
```ts src/client.ts class Client
|
|
40
40
|
export class Client {
|
|
41
41
|
#context: ClientContext;
|
|
42
|
-
|
|
43
42
|
constructor(endpoint: string, options?: ClientOptions) {
|
|
44
43
|
this.#context = createClientContext(endpoint, options);
|
|
45
44
|
}
|
|
@@ -54,21 +53,17 @@ It should generate an operation for foo
|
|
|
54
53
|
```ts src/api/clientOperations.ts function foo
|
|
55
54
|
export async function foo(client: ClientContext, options?: FooOptions): Promise<void> {
|
|
56
55
|
const path = parse("/").expand({});
|
|
57
|
-
|
|
58
56
|
const httpRequestOptions = {
|
|
59
57
|
headers: {},
|
|
60
58
|
};
|
|
61
|
-
|
|
62
59
|
const response = await client.pathUnchecked(path).get(httpRequestOptions);
|
|
63
60
|
|
|
64
61
|
if (typeof options?.operationOptions?.onResponse === "function") {
|
|
65
62
|
options?.operationOptions?.onResponse(response);
|
|
66
63
|
}
|
|
67
|
-
|
|
68
64
|
if (+response.status === 204 && !response.body) {
|
|
69
65
|
return;
|
|
70
66
|
}
|
|
71
|
-
|
|
72
67
|
throw createRestError(response);
|
|
73
68
|
}
|
|
74
69
|
```
|
|
@@ -37,7 +37,6 @@ import {
|
|
|
37
37
|
|
|
38
38
|
export class FooClient {
|
|
39
39
|
#context: FooClientContext;
|
|
40
|
-
|
|
41
40
|
constructor(endpoint: string, options?: FooClientOptions) {
|
|
42
41
|
this.#context = createFooClientContext(endpoint, options);
|
|
43
42
|
}
|
|
@@ -60,7 +59,6 @@ import {
|
|
|
60
59
|
|
|
61
60
|
export class BarClient {
|
|
62
61
|
#context: BarClientContext;
|
|
63
|
-
|
|
64
62
|
constructor(endpoint: string, options?: BarClientOptions) {
|
|
65
63
|
this.#context = createBarClientContext(endpoint, options);
|
|
66
64
|
}
|
|
@@ -77,10 +77,8 @@ export class DemoServiceClient {
|
|
|
77
77
|
this.widgetsClient = new WidgetsClient(endpoint, options);
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
|
|
81
80
|
export class WidgetsClient {
|
|
82
81
|
#context: WidgetsClientContext;
|
|
83
|
-
|
|
84
82
|
constructor(endpoint: string, options?: WidgetsClientOptions) {
|
|
85
83
|
this.#context = createWidgetsClientContext(endpoint, options);
|
|
86
84
|
}
|
|
@@ -22,27 +22,23 @@ export async function foo(
|
|
|
22
22
|
options?: FooOptions,
|
|
23
23
|
): Promise<Uint8Array> {
|
|
24
24
|
const path = parse("/default").expand({});
|
|
25
|
-
|
|
26
25
|
const httpRequestOptions = {
|
|
27
26
|
headers: {
|
|
28
27
|
"content-type": options?.contentType ?? "application/octet-stream",
|
|
29
28
|
},
|
|
30
29
|
body: value,
|
|
31
30
|
};
|
|
32
|
-
|
|
33
31
|
const response = await client.pathUnchecked(path).post(httpRequestOptions);
|
|
34
32
|
|
|
35
33
|
if (typeof options?.operationOptions?.onResponse === "function") {
|
|
36
34
|
options?.operationOptions?.onResponse(response);
|
|
37
35
|
}
|
|
38
|
-
|
|
39
36
|
if (
|
|
40
37
|
+response.status === 200 &&
|
|
41
38
|
response.headers["content-type"]?.includes("application/octet-stream")
|
|
42
39
|
) {
|
|
43
40
|
return response.body!;
|
|
44
41
|
}
|
|
45
|
-
|
|
46
42
|
throw createRestError(response);
|
|
47
43
|
}
|
|
48
44
|
```
|
|
@@ -23,24 +23,20 @@ export async function foo(
|
|
|
23
23
|
options?: FooOptions,
|
|
24
24
|
): Promise<BytesBody> {
|
|
25
25
|
const path = parse("/default").expand({});
|
|
26
|
-
|
|
27
26
|
const httpRequestOptions = {
|
|
28
27
|
headers: {},
|
|
29
28
|
body: {
|
|
30
29
|
value: encodeUint8Array(value, "base64")!,
|
|
31
30
|
},
|
|
32
31
|
};
|
|
33
|
-
|
|
34
32
|
const response = await client.pathUnchecked(path).post(httpRequestOptions);
|
|
35
33
|
|
|
36
34
|
if (typeof options?.operationOptions?.onResponse === "function") {
|
|
37
35
|
options?.operationOptions?.onResponse(response);
|
|
38
36
|
}
|
|
39
|
-
|
|
40
37
|
if (+response.status === 200 && response.headers["content-type"]?.includes("application/json")) {
|
|
41
38
|
return jsonBytesBodyToApplicationTransform(response.body)!;
|
|
42
39
|
}
|
|
43
|
-
|
|
44
40
|
throw createRestError(response);
|
|
45
41
|
}
|
|
46
42
|
```
|
|
@@ -52,7 +48,6 @@ export function jsonBytesBodyToApplicationTransform(input_?: any): BytesBody {
|
|
|
52
48
|
if (!input_) {
|
|
53
49
|
return input_ as any;
|
|
54
50
|
}
|
|
55
|
-
|
|
56
51
|
return {
|
|
57
52
|
value: decodeBase64(input_.value)!,
|
|
58
53
|
}!;
|
|
@@ -27,21 +27,17 @@ export async function get(
|
|
|
27
27
|
options?: GetOptions,
|
|
28
28
|
): Promise<ModelWithBytes> {
|
|
29
29
|
const path = parse("/").expand({});
|
|
30
|
-
|
|
31
30
|
const httpRequestOptions = {
|
|
32
31
|
headers: {},
|
|
33
32
|
};
|
|
34
|
-
|
|
35
33
|
const response = await client.pathUnchecked(path).get(httpRequestOptions);
|
|
36
34
|
|
|
37
35
|
if (typeof options?.operationOptions?.onResponse === "function") {
|
|
38
36
|
options?.operationOptions?.onResponse(response);
|
|
39
37
|
}
|
|
40
|
-
|
|
41
38
|
if (+response.status === 200 && response.headers["content-type"]?.includes("application/json")) {
|
|
42
39
|
return jsonModelWithBytesToApplicationTransform(response.body)!;
|
|
43
40
|
}
|
|
44
|
-
|
|
45
41
|
throw createRestError(response);
|
|
46
42
|
}
|
|
47
43
|
```
|
|
@@ -55,7 +51,6 @@ export function jsonModelWithBytesToApplicationTransform(input_?: any): ModelWit
|
|
|
55
51
|
if (!input_) {
|
|
56
52
|
return input_ as any;
|
|
57
53
|
}
|
|
58
|
-
|
|
59
54
|
return {
|
|
60
55
|
requiredProperty: input_.requiredProperty,
|
|
61
56
|
nullableProperty: decodeBase64(input_.nullableProperty)!,
|
|
@@ -77,7 +72,6 @@ export async function put(
|
|
|
77
72
|
options?: PutOptions,
|
|
78
73
|
): Promise<void> {
|
|
79
74
|
const path = parse("/").expand({});
|
|
80
|
-
|
|
81
75
|
const httpRequestOptions = {
|
|
82
76
|
headers: {},
|
|
83
77
|
body: {
|
|
@@ -85,17 +79,14 @@ export async function put(
|
|
|
85
79
|
nullableProperty: encodeUint8Array(nullableProperty, "base64")!,
|
|
86
80
|
},
|
|
87
81
|
};
|
|
88
|
-
|
|
89
82
|
const response = await client.pathUnchecked(path).put(httpRequestOptions);
|
|
90
83
|
|
|
91
84
|
if (typeof options?.operationOptions?.onResponse === "function") {
|
|
92
85
|
options?.operationOptions?.onResponse(response);
|
|
93
86
|
}
|
|
94
|
-
|
|
95
87
|
if (+response.status === 204 && !response.body) {
|
|
96
88
|
return;
|
|
97
89
|
}
|
|
98
|
-
|
|
99
90
|
throw createRestError(response);
|
|
100
91
|
}
|
|
101
92
|
```
|
|
@@ -113,24 +104,20 @@ export async function post(
|
|
|
113
104
|
options?: PostOptions,
|
|
114
105
|
): Promise<void> {
|
|
115
106
|
const path = parse("/").expand({});
|
|
116
|
-
|
|
117
107
|
const httpRequestOptions = {
|
|
118
108
|
headers: {},
|
|
119
109
|
body: {
|
|
120
110
|
body: jsonModelWithBytesToTransportTransform(body),
|
|
121
111
|
},
|
|
122
112
|
};
|
|
123
|
-
|
|
124
113
|
const response = await client.pathUnchecked(path).post(httpRequestOptions);
|
|
125
114
|
|
|
126
115
|
if (typeof options?.operationOptions?.onResponse === "function") {
|
|
127
116
|
options?.operationOptions?.onResponse(response);
|
|
128
117
|
}
|
|
129
|
-
|
|
130
118
|
if (+response.status === 204 && !response.body) {
|
|
131
119
|
return;
|
|
132
120
|
}
|
|
133
|
-
|
|
134
121
|
throw createRestError(response);
|
|
135
122
|
}
|
|
136
123
|
```
|
|
@@ -144,7 +131,6 @@ export function jsonModelWithBytesToTransportTransform(input_?: ModelWithBytes |
|
|
|
144
131
|
if (!input_) {
|
|
145
132
|
return input_ as any;
|
|
146
133
|
}
|
|
147
|
-
|
|
148
134
|
return {
|
|
149
135
|
requiredProperty: input_.requiredProperty,
|
|
150
136
|
nullableProperty: encodeUint8Array(input_.nullableProperty, "base64")!,
|
|
@@ -24,23 +24,19 @@ export async function defaultEncoding(
|
|
|
24
24
|
options?: DefaultEncodingOptions,
|
|
25
25
|
): Promise<void> {
|
|
26
26
|
const path = parse("/default").expand({});
|
|
27
|
-
|
|
28
27
|
const httpRequestOptions = {
|
|
29
28
|
headers: {
|
|
30
29
|
value: encodeUint8Array(value, "base64")!,
|
|
31
30
|
},
|
|
32
31
|
};
|
|
33
|
-
|
|
34
32
|
const response = await client.pathUnchecked(path).get(httpRequestOptions);
|
|
35
33
|
|
|
36
34
|
if (typeof options?.operationOptions?.onResponse === "function") {
|
|
37
35
|
options?.operationOptions?.onResponse(response);
|
|
38
36
|
}
|
|
39
|
-
|
|
40
37
|
if (+response.status === 204 && !response.body) {
|
|
41
38
|
return;
|
|
42
39
|
}
|
|
43
|
-
|
|
44
40
|
throw createRestError(response);
|
|
45
41
|
}
|
|
46
42
|
```
|
|
@@ -70,7 +66,6 @@ export async function defaultEncoding(
|
|
|
70
66
|
options?: DefaultEncodingOptions,
|
|
71
67
|
): Promise<void> {
|
|
72
68
|
const path = parse("/default").expand({});
|
|
73
|
-
|
|
74
69
|
const httpRequestOptions = {
|
|
75
70
|
headers: {
|
|
76
71
|
...(options?.value && {
|
|
@@ -78,17 +73,14 @@ export async function defaultEncoding(
|
|
|
78
73
|
}),
|
|
79
74
|
},
|
|
80
75
|
};
|
|
81
|
-
|
|
82
76
|
const response = await client.pathUnchecked(path).get(httpRequestOptions);
|
|
83
77
|
|
|
84
78
|
if (typeof options?.operationOptions?.onResponse === "function") {
|
|
85
79
|
options?.operationOptions?.onResponse(response);
|
|
86
80
|
}
|
|
87
|
-
|
|
88
81
|
if (+response.status === 204 && !response.body) {
|
|
89
82
|
return;
|
|
90
83
|
}
|
|
91
|
-
|
|
92
84
|
throw createRestError(response);
|
|
93
85
|
}
|
|
94
86
|
```
|
|
@@ -120,23 +112,19 @@ export async function get(
|
|
|
120
112
|
options?: GetOptions,
|
|
121
113
|
): Promise<void> {
|
|
122
114
|
const path = parse("/default").expand({});
|
|
123
|
-
|
|
124
115
|
const httpRequestOptions = {
|
|
125
116
|
headers: {
|
|
126
117
|
value: encodeUint8Array(value, "base64")!,
|
|
127
118
|
},
|
|
128
119
|
};
|
|
129
|
-
|
|
130
120
|
const response = await client.pathUnchecked(path).get(httpRequestOptions);
|
|
131
121
|
|
|
132
122
|
if (typeof options?.operationOptions?.onResponse === "function") {
|
|
133
123
|
options?.operationOptions?.onResponse(response);
|
|
134
124
|
}
|
|
135
|
-
|
|
136
125
|
if (+response.status === 204 && !response.body) {
|
|
137
126
|
return;
|
|
138
127
|
}
|
|
139
|
-
|
|
140
128
|
throw createRestError(response);
|
|
141
129
|
}
|
|
142
130
|
```
|
|
@@ -24,23 +24,19 @@ export async function defaultEncoding(
|
|
|
24
24
|
options?: DefaultEncodingOptions,
|
|
25
25
|
): Promise<void> {
|
|
26
26
|
const path = parse("/default").expand({});
|
|
27
|
-
|
|
28
27
|
const httpRequestOptions = {
|
|
29
28
|
headers: {
|
|
30
29
|
value: dateRfc7231Serializer(value),
|
|
31
30
|
},
|
|
32
31
|
};
|
|
33
|
-
|
|
34
32
|
const response = await client.pathUnchecked(path).get(httpRequestOptions);
|
|
35
33
|
|
|
36
34
|
if (typeof options?.operationOptions?.onResponse === "function") {
|
|
37
35
|
options?.operationOptions?.onResponse(response);
|
|
38
36
|
}
|
|
39
|
-
|
|
40
37
|
if (+response.status === 204 && !response.body) {
|
|
41
38
|
return;
|
|
42
39
|
}
|
|
43
|
-
|
|
44
40
|
throw createRestError(response);
|
|
45
41
|
}
|
|
46
42
|
```
|
|
@@ -70,23 +66,19 @@ export async function defaultEncoding(
|
|
|
70
66
|
options?: DefaultEncodingOptions,
|
|
71
67
|
): Promise<void> {
|
|
72
68
|
const path = parse("/default").expand({});
|
|
73
|
-
|
|
74
69
|
const httpRequestOptions = {
|
|
75
70
|
headers: {
|
|
76
71
|
...(options?.value && { value: dateRfc7231Serializer(options?.value) }),
|
|
77
72
|
},
|
|
78
73
|
};
|
|
79
|
-
|
|
80
74
|
const response = await client.pathUnchecked(path).get(httpRequestOptions);
|
|
81
75
|
|
|
82
76
|
if (typeof options?.operationOptions?.onResponse === "function") {
|
|
83
77
|
options?.operationOptions?.onResponse(response);
|
|
84
78
|
}
|
|
85
|
-
|
|
86
79
|
if (+response.status === 204 && !response.body) {
|
|
87
80
|
return;
|
|
88
81
|
}
|
|
89
|
-
|
|
90
82
|
throw createRestError(response);
|
|
91
83
|
}
|
|
92
84
|
```
|
|
@@ -118,23 +110,19 @@ export async function get(
|
|
|
118
110
|
options?: GetOptions,
|
|
119
111
|
): Promise<void> {
|
|
120
112
|
const path = parse("/default").expand({});
|
|
121
|
-
|
|
122
113
|
const httpRequestOptions = {
|
|
123
114
|
headers: {
|
|
124
115
|
value: dateRfc3339Serializer(value),
|
|
125
116
|
},
|
|
126
117
|
};
|
|
127
|
-
|
|
128
118
|
const response = await client.pathUnchecked(path).get(httpRequestOptions);
|
|
129
119
|
|
|
130
120
|
if (typeof options?.operationOptions?.onResponse === "function") {
|
|
131
121
|
options?.operationOptions?.onResponse(response);
|
|
132
122
|
}
|
|
133
|
-
|
|
134
123
|
if (+response.status === 204 && !response.body) {
|
|
135
124
|
return;
|
|
136
125
|
}
|
|
137
|
-
|
|
138
126
|
throw createRestError(response);
|
|
139
127
|
}
|
|
140
128
|
```
|
|
@@ -166,23 +154,19 @@ export async function get(
|
|
|
166
154
|
options?: GetOptions,
|
|
167
155
|
): Promise<void> {
|
|
168
156
|
const path = parse("/default").expand({});
|
|
169
|
-
|
|
170
157
|
const httpRequestOptions = {
|
|
171
158
|
headers: {
|
|
172
159
|
value: dateRfc7231Serializer(value),
|
|
173
160
|
},
|
|
174
161
|
};
|
|
175
|
-
|
|
176
162
|
const response = await client.pathUnchecked(path).get(httpRequestOptions);
|
|
177
163
|
|
|
178
164
|
if (typeof options?.operationOptions?.onResponse === "function") {
|
|
179
165
|
options?.operationOptions?.onResponse(response);
|
|
180
166
|
}
|
|
181
|
-
|
|
182
167
|
if (+response.status === 204 && !response.body) {
|
|
183
168
|
return;
|
|
184
169
|
}
|
|
185
|
-
|
|
186
170
|
throw createRestError(response);
|
|
187
171
|
}
|
|
188
172
|
```
|
|
@@ -214,23 +198,19 @@ export async function get(
|
|
|
214
198
|
options?: GetOptions,
|
|
215
199
|
): Promise<void> {
|
|
216
200
|
const path = parse("/default").expand({});
|
|
217
|
-
|
|
218
201
|
const httpRequestOptions = {
|
|
219
202
|
headers: {
|
|
220
203
|
value: dateUnixTimestampSerializer(value),
|
|
221
204
|
},
|
|
222
205
|
};
|
|
223
|
-
|
|
224
206
|
const response = await client.pathUnchecked(path).get(httpRequestOptions);
|
|
225
207
|
|
|
226
208
|
if (typeof options?.operationOptions?.onResponse === "function") {
|
|
227
209
|
options?.operationOptions?.onResponse(response);
|
|
228
210
|
}
|
|
229
|
-
|
|
230
211
|
if (+response.status === 204 && !response.body) {
|
|
231
212
|
return;
|
|
232
213
|
}
|
|
233
|
-
|
|
234
214
|
throw createRestError(response);
|
|
235
215
|
}
|
|
236
216
|
```
|
|
@@ -18,21 +18,17 @@ model BytesProperty {
|
|
|
18
18
|
```ts src/api/testClientOperations.ts function get
|
|
19
19
|
export async function get(client: TestClientContext, options?: GetOptions): Promise<BytesProperty> {
|
|
20
20
|
const path = parse("/bytes").expand({});
|
|
21
|
-
|
|
22
21
|
const httpRequestOptions = {
|
|
23
22
|
headers: {},
|
|
24
23
|
};
|
|
25
|
-
|
|
26
24
|
const response = await client.pathUnchecked(path).get(httpRequestOptions);
|
|
27
25
|
|
|
28
26
|
if (typeof options?.operationOptions?.onResponse === "function") {
|
|
29
27
|
options?.operationOptions?.onResponse(response);
|
|
30
28
|
}
|
|
31
|
-
|
|
32
29
|
if (+response.status === 200 && response.headers["content-type"]?.includes("application/json")) {
|
|
33
30
|
return jsonBytesPropertyToApplicationTransform(response.body)!;
|
|
34
31
|
}
|
|
35
|
-
|
|
36
32
|
throw createRestError(response);
|
|
37
33
|
}
|
|
38
34
|
```
|
|
@@ -42,7 +38,6 @@ export function jsonBytesPropertyToApplicationTransform(input_?: any): BytesProp
|
|
|
42
38
|
if (!input_) {
|
|
43
39
|
return input_ as any;
|
|
44
40
|
}
|
|
45
|
-
|
|
46
41
|
return {
|
|
47
42
|
property: decodeBase64(input_.property)!,
|
|
48
43
|
}!;
|
|
@@ -26,21 +26,17 @@ export async function defaultEncoding(
|
|
|
26
26
|
const path = parse("/default{?value}").expand({
|
|
27
27
|
value: encodeUint8Array(value, "base64url")!,
|
|
28
28
|
});
|
|
29
|
-
|
|
30
29
|
const httpRequestOptions = {
|
|
31
30
|
headers: {},
|
|
32
31
|
};
|
|
33
|
-
|
|
34
32
|
const response = await client.pathUnchecked(path).get(httpRequestOptions);
|
|
35
33
|
|
|
36
34
|
if (typeof options?.operationOptions?.onResponse === "function") {
|
|
37
35
|
options?.operationOptions?.onResponse(response);
|
|
38
36
|
}
|
|
39
|
-
|
|
40
37
|
if (+response.status === 204 && !response.body) {
|
|
41
38
|
return;
|
|
42
39
|
}
|
|
43
|
-
|
|
44
40
|
throw createRestError(response);
|
|
45
41
|
}
|
|
46
42
|
```
|