@typespec/http-client-js 0.1.0 → 0.2.0-dev.10
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/.github/copilot-instructions.md +193 -0
- package/README.md +31 -15
- 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 +21 -14
- 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/testing/client-options.d.ts.map +1 -1
- package/dist/src/components/testing/client-options.js +0 -2
- package/dist/src/components/testing/client-options.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 +5 -10
- 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 +23 -13
- 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/unpack-model-property.d.ts.map +1 -1
- package/dist/src/components/utils/unpack-model-property.js +11 -2
- package/dist/src/components/utils/unpack-model-property.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/lib.d.ts.map +1 -1
- package/dist/src/lib.js +2 -1
- package/dist/src/lib.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/eng/scripts/emit-e2e.js +1 -1
- package/package.json +14 -13
- 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 +21 -9
- 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/testing/client-options.tsx +0 -3
- 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 +17 -30
- 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 +16 -13
- package/src/components/transforms/operation-transform-declaration.tsx +24 -7
- package/src/components/transforms/operation-transform-expression.tsx +12 -5
- package/src/components/utils/unpack-model-property.ts +13 -2
- package/src/components/utils/url-template.tsx +10 -6
- package/src/emitter.tsx +4 -3
- package/src/lib.ts +6 -1
- package/src/utils/operations.ts +96 -1
- package/src/utils/parameters.tsx +5 -1
- package/test/e2e/http/payload/multipart/main.test.ts +20 -24
- package/test/e2e/http/type/property/additional-properties/spreads.test.ts +4 -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 +2 -11
- package/test/scenarios/multipart/file.md +0 -12
- package/test/scenarios/multipart/file_content_type.md +15 -5
- package/test/scenarios/multipart/non-string-float.md +50 -0
- 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.md +1 -1
- package/test/scenarios/serializers/discriminated_union_spread.md +1 -5
- package/test/scenarios/serializers/multipart.md +0 -4
- package/test/scenarios/serializers/polymorphic_single_level_inheritance.md +0 -5
- package/test/scenarios/serializers/property_references_property.md +72 -0
- 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
|
@@ -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
|
```
|
|
@@ -26,21 +26,17 @@ export async function defaultEncoding(
|
|
|
26
26
|
const path = parse("/default{?value}").expand({
|
|
27
27
|
value: dateRfc3339Serializer(value),
|
|
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
|
```
|
|
@@ -72,21 +68,17 @@ export async function defaultEncoding(
|
|
|
72
68
|
const path = parse("/default{?value}").expand({
|
|
73
69
|
...(options?.value && { value: dateRfc3339Serializer(options?.value) }),
|
|
74
70
|
});
|
|
75
|
-
|
|
76
71
|
const httpRequestOptions = {
|
|
77
72
|
headers: {},
|
|
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
|
```
|
|
@@ -120,21 +112,17 @@ export async function get(
|
|
|
120
112
|
const path = parse("/default{?value}").expand({
|
|
121
113
|
value: dateRfc3339Serializer(value),
|
|
122
114
|
});
|
|
123
|
-
|
|
124
115
|
const httpRequestOptions = {
|
|
125
116
|
headers: {},
|
|
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
|
```
|
|
@@ -168,21 +156,17 @@ export async function get(
|
|
|
168
156
|
const path = parse("/default{?value}").expand({
|
|
169
157
|
value: dateRfc7231Serializer(value),
|
|
170
158
|
});
|
|
171
|
-
|
|
172
159
|
const httpRequestOptions = {
|
|
173
160
|
headers: {},
|
|
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
|
```
|
|
@@ -216,21 +200,17 @@ export async function get(
|
|
|
216
200
|
const path = parse("/default{?value}").expand({
|
|
217
201
|
value: dateUnixTimestampSerializer(value),
|
|
218
202
|
});
|
|
219
|
-
|
|
220
203
|
const httpRequestOptions = {
|
|
221
204
|
headers: {},
|
|
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
|
```
|
|
@@ -24,21 +24,17 @@ interface Widgets {
|
|
|
24
24
|
```ts src/api/widgetsClient/widgetsClientOperations.ts function read
|
|
25
25
|
export async function read(client: WidgetsClientContext, options?: ReadOptions): Promise<void> {
|
|
26
26
|
const path = parse("/widgets").expand({});
|
|
27
|
-
|
|
28
27
|
const httpRequestOptions = {
|
|
29
28
|
headers: {},
|
|
30
29
|
};
|
|
31
|
-
|
|
32
30
|
const response = await client.pathUnchecked(path).get(httpRequestOptions);
|
|
33
31
|
|
|
34
32
|
if (typeof options?.operationOptions?.onResponse === "function") {
|
|
35
33
|
options?.operationOptions?.onResponse(response);
|
|
36
34
|
}
|
|
37
|
-
|
|
38
35
|
if (+response.status === 204 && !response.body) {
|
|
39
36
|
return;
|
|
40
37
|
}
|
|
41
|
-
|
|
42
38
|
throw createRestError(response);
|
|
43
39
|
}
|
|
44
40
|
```
|
|
@@ -87,7 +83,6 @@ export async function read(
|
|
|
87
83
|
id: id,
|
|
88
84
|
foo: foo,
|
|
89
85
|
});
|
|
90
|
-
|
|
91
86
|
const httpRequestOptions = {
|
|
92
87
|
headers: {
|
|
93
88
|
etag: etag,
|
|
@@ -96,17 +91,14 @@ export async function read(
|
|
|
96
91
|
name: name,
|
|
97
92
|
},
|
|
98
93
|
};
|
|
99
|
-
|
|
100
94
|
const response = await client.pathUnchecked(path).post(httpRequestOptions);
|
|
101
95
|
|
|
102
96
|
if (typeof options?.operationOptions?.onResponse === "function") {
|
|
103
97
|
options?.operationOptions?.onResponse(response);
|
|
104
98
|
}
|
|
105
|
-
|
|
106
99
|
if (+response.status === 204 && !response.body) {
|
|
107
100
|
return;
|
|
108
101
|
}
|
|
109
|
-
|
|
110
102
|
throw createRestError(response);
|
|
111
103
|
}
|
|
112
104
|
```
|
|
@@ -141,22 +133,18 @@ export async function read(
|
|
|
141
133
|
options?: ReadOptions,
|
|
142
134
|
): Promise<void> {
|
|
143
135
|
const path = parse("/widgets").expand({});
|
|
144
|
-
|
|
145
136
|
const httpRequestOptions = {
|
|
146
137
|
headers: {},
|
|
147
138
|
body: count,
|
|
148
139
|
};
|
|
149
|
-
|
|
150
140
|
const response = await client.pathUnchecked(path).get(httpRequestOptions);
|
|
151
141
|
|
|
152
142
|
if (typeof options?.operationOptions?.onResponse === "function") {
|
|
153
143
|
options?.operationOptions?.onResponse(response);
|
|
154
144
|
}
|
|
155
|
-
|
|
156
145
|
if (+response.status === 204 && !response.body) {
|
|
157
146
|
return;
|
|
158
147
|
}
|
|
159
|
-
|
|
160
148
|
throw createRestError(response);
|
|
161
149
|
}
|
|
162
150
|
```
|
|
@@ -24,21 +24,17 @@ interface Widgets {
|
|
|
24
24
|
```ts src/api/widgetsClient/widgetsClientOperations.ts function read
|
|
25
25
|
export async function read(client: WidgetsClientContext, options?: ReadOptions): Promise<void> {
|
|
26
26
|
const path = parse("/widgets").expand({});
|
|
27
|
-
|
|
28
27
|
const httpRequestOptions = {
|
|
29
28
|
headers: {},
|
|
30
29
|
};
|
|
31
|
-
|
|
32
30
|
const response = await client.pathUnchecked(path).get(httpRequestOptions);
|
|
33
31
|
|
|
34
32
|
if (typeof options?.operationOptions?.onResponse === "function") {
|
|
35
33
|
options?.operationOptions?.onResponse(response);
|
|
36
34
|
}
|
|
37
|
-
|
|
38
35
|
if (+response.status === 204 && !response.body) {
|
|
39
36
|
return;
|
|
40
37
|
}
|
|
41
|
-
|
|
42
38
|
throw createRestError(response);
|
|
43
39
|
}
|
|
44
40
|
```
|
|
@@ -81,7 +77,6 @@ export function jsonWidgetToApplicationTransform(input_?: any): Widget {
|
|
|
81
77
|
if (!input_) {
|
|
82
78
|
return input_ as any;
|
|
83
79
|
}
|
|
84
|
-
|
|
85
80
|
return {
|
|
86
81
|
name: input_.name,
|
|
87
82
|
age: input_.age,
|
|
@@ -96,21 +91,17 @@ The function reads a `Widget` instance from the response body, ensuring it only
|
|
|
96
91
|
```ts src/api/widgetsClient/widgetsClientOperations.ts function read
|
|
97
92
|
export async function read(client: WidgetsClientContext, options?: ReadOptions): Promise<Widget> {
|
|
98
93
|
const path = parse("/widgets").expand({});
|
|
99
|
-
|
|
100
94
|
const httpRequestOptions = {
|
|
101
95
|
headers: {},
|
|
102
96
|
};
|
|
103
|
-
|
|
104
97
|
const response = await client.pathUnchecked(path).get(httpRequestOptions);
|
|
105
98
|
|
|
106
99
|
if (typeof options?.operationOptions?.onResponse === "function") {
|
|
107
100
|
options?.operationOptions?.onResponse(response);
|
|
108
101
|
}
|
|
109
|
-
|
|
110
102
|
if (+response.status === 200 && response.headers["content-type"]?.includes("application/json")) {
|
|
111
103
|
return jsonWidgetToApplicationTransform(response.body)!;
|
|
112
104
|
}
|
|
113
|
-
|
|
114
105
|
throw createRestError(response);
|
|
115
106
|
}
|
|
116
107
|
```
|
|
@@ -154,25 +145,20 @@ export async function read(
|
|
|
154
145
|
options?: ReadOptions,
|
|
155
146
|
): Promise<Widget | void> {
|
|
156
147
|
const path = parse("/widgets").expand({});
|
|
157
|
-
|
|
158
148
|
const httpRequestOptions = {
|
|
159
149
|
headers: {},
|
|
160
150
|
};
|
|
161
|
-
|
|
162
151
|
const response = await client.pathUnchecked(path).get(httpRequestOptions);
|
|
163
152
|
|
|
164
153
|
if (typeof options?.operationOptions?.onResponse === "function") {
|
|
165
154
|
options?.operationOptions?.onResponse(response);
|
|
166
155
|
}
|
|
167
|
-
|
|
168
156
|
if (+response.status === 200 && response.headers["content-type"]?.includes("application/json")) {
|
|
169
157
|
return jsonWidgetToApplicationTransform(response.body)!;
|
|
170
158
|
}
|
|
171
|
-
|
|
172
159
|
if (+response.status === 204 && !response.body) {
|
|
173
160
|
return;
|
|
174
161
|
}
|
|
175
|
-
|
|
176
162
|
throw createRestError(response);
|
|
177
163
|
}
|
|
178
164
|
```
|
|
@@ -222,25 +208,20 @@ TODO: need to implement xml serialization
|
|
|
222
208
|
```ts src/api/widgetsClient/widgetsClientOperations.ts function read
|
|
223
209
|
export async function read(client: WidgetsClientContext, options?: ReadOptions): Promise<Widget> {
|
|
224
210
|
const path = parse("/widgets").expand({});
|
|
225
|
-
|
|
226
211
|
const httpRequestOptions = {
|
|
227
212
|
headers: {},
|
|
228
213
|
};
|
|
229
|
-
|
|
230
214
|
const response = await client.pathUnchecked(path).get(httpRequestOptions);
|
|
231
215
|
|
|
232
216
|
if (typeof options?.operationOptions?.onResponse === "function") {
|
|
233
217
|
options?.operationOptions?.onResponse(response);
|
|
234
218
|
}
|
|
235
|
-
|
|
236
219
|
if (+response.status === 200 && response.headers["content-type"]?.includes("application/json")) {
|
|
237
220
|
return jsonWidgetToApplicationTransform(response.body)!;
|
|
238
221
|
}
|
|
239
|
-
|
|
240
222
|
if (+response.status === 200 && response.headers["content-type"]?.includes("application/xml")) {
|
|
241
223
|
return jsonWidgetToApplicationTransform(response.body)!;
|
|
242
224
|
}
|
|
243
|
-
|
|
244
225
|
throw createRestError(response);
|
|
245
226
|
}
|
|
246
227
|
```
|
|
@@ -32,7 +32,6 @@ import {
|
|
|
32
32
|
|
|
33
33
|
export class TestClient {
|
|
34
34
|
#context: TestClientContext;
|
|
35
|
-
|
|
36
35
|
constructor(endpoint: string, options?: TestClientOptions) {
|
|
37
36
|
this.#context = createTestClientContext(endpoint, options);
|
|
38
37
|
}
|
|
@@ -63,7 +62,6 @@ export function jsonWidgetToTransportTransform(input_?: Widget | null): any {
|
|
|
63
62
|
if (!input_) {
|
|
64
63
|
return input_ as any;
|
|
65
64
|
}
|
|
66
|
-
|
|
67
65
|
return {
|
|
68
66
|
id: input_.id,
|
|
69
67
|
total_weight: input_.totalWeight,
|
|
@@ -114,21 +112,17 @@ A function named `foo` is generated to handle the HTTP request. It prepares the
|
|
|
114
112
|
```ts src/api/testClientOperations.ts function foo
|
|
115
113
|
export async function foo(client: TestClientContext, options?: FooOptions): Promise<Widget> {
|
|
116
114
|
const path = parse("/").expand({});
|
|
117
|
-
|
|
118
115
|
const httpRequestOptions = {
|
|
119
116
|
headers: {},
|
|
120
117
|
};
|
|
121
|
-
|
|
122
118
|
const response = await client.pathUnchecked(path).get(httpRequestOptions);
|
|
123
119
|
|
|
124
120
|
if (typeof options?.operationOptions?.onResponse === "function") {
|
|
125
121
|
options?.operationOptions?.onResponse(response);
|
|
126
122
|
}
|
|
127
|
-
|
|
128
123
|
if (+response.status === 200 && response.headers["content-type"]?.includes("application/json")) {
|
|
129
124
|
return jsonWidgetToApplicationTransform(response.body)!;
|
|
130
125
|
}
|
|
131
|
-
|
|
132
126
|
throw createRestError(response);
|
|
133
127
|
}
|
|
134
128
|
```
|
|
@@ -15,23 +15,19 @@ model Foo {
|
|
|
15
15
|
```ts src/api/testClientOperations.ts function foo
|
|
16
16
|
export async function foo(client: TestClientContext, options?: FooOptions): Promise<Foo> {
|
|
17
17
|
const path = parse("/").expand({});
|
|
18
|
-
|
|
19
18
|
const httpRequestOptions = {
|
|
20
19
|
headers: {
|
|
21
20
|
accept: options?.accept ?? "application/xml",
|
|
22
21
|
},
|
|
23
22
|
};
|
|
24
|
-
|
|
25
23
|
const response = await client.pathUnchecked(path).get(httpRequestOptions);
|
|
26
24
|
|
|
27
25
|
if (typeof options?.operationOptions?.onResponse === "function") {
|
|
28
26
|
options?.operationOptions?.onResponse(response);
|
|
29
27
|
}
|
|
30
|
-
|
|
31
28
|
if (+response.status === 200 && response.headers["content-type"]?.includes("application/json")) {
|
|
32
29
|
return jsonFooToApplicationTransform(response.body)!;
|
|
33
30
|
}
|
|
34
|
-
|
|
35
31
|
throw createRestError(response);
|
|
36
32
|
}
|
|
37
33
|
```
|
|
@@ -36,7 +36,6 @@ export async function foo(
|
|
|
36
36
|
options?: FooOptions,
|
|
37
37
|
): Promise<void> {
|
|
38
38
|
const path = parse("/").expand({});
|
|
39
|
-
|
|
40
39
|
const httpRequestOptions = {
|
|
41
40
|
headers: {},
|
|
42
41
|
body: {
|
|
@@ -46,17 +45,14 @@ export async function foo(
|
|
|
46
45
|
is_required: options?.isRequired,
|
|
47
46
|
},
|
|
48
47
|
};
|
|
49
|
-
|
|
50
48
|
const response = await client.pathUnchecked(path).post(httpRequestOptions);
|
|
51
49
|
|
|
52
50
|
if (typeof options?.operationOptions?.onResponse === "function") {
|
|
53
51
|
options?.operationOptions?.onResponse(response);
|
|
54
52
|
}
|
|
55
|
-
|
|
56
53
|
if (+response.status === 204 && !response.body) {
|
|
57
54
|
return;
|
|
58
55
|
}
|
|
59
|
-
|
|
60
56
|
throw createRestError(response);
|
|
61
57
|
}
|
|
62
58
|
```
|
|
@@ -30,7 +30,6 @@ export async function foo(
|
|
|
30
30
|
options?: FooOptions,
|
|
31
31
|
): Promise<void> {
|
|
32
32
|
const path = parse("/").expand({});
|
|
33
|
-
|
|
34
33
|
const httpRequestOptions = {
|
|
35
34
|
headers: {},
|
|
36
35
|
body: {
|
|
@@ -40,17 +39,14 @@ export async function foo(
|
|
|
40
39
|
is_required: options?.isRequired,
|
|
41
40
|
},
|
|
42
41
|
};
|
|
43
|
-
|
|
44
42
|
const response = await client.pathUnchecked(path).post(httpRequestOptions);
|
|
45
43
|
|
|
46
44
|
if (typeof options?.operationOptions?.onResponse === "function") {
|
|
47
45
|
options?.operationOptions?.onResponse(response);
|
|
48
46
|
}
|
|
49
|
-
|
|
50
47
|
if (+response.status === 204 && !response.body) {
|
|
51
48
|
return;
|
|
52
49
|
}
|
|
53
|
-
|
|
54
50
|
throw createRestError(response);
|
|
55
51
|
}
|
|
56
52
|
```
|
|
@@ -20,22 +20,18 @@ op omit(@body body?: BodyModel): NoContentResponse;
|
|
|
20
20
|
```ts src/api/testClientOperations.ts function set
|
|
21
21
|
export async function set(client: TestClientContext, options?: SetOptions): Promise<void> {
|
|
22
22
|
const path = parse("/set").expand({});
|
|
23
|
-
|
|
24
23
|
const httpRequestOptions = {
|
|
25
24
|
headers: {},
|
|
26
25
|
body: jsonBodyModelToTransportTransform(options?.body),
|
|
27
26
|
};
|
|
28
|
-
|
|
29
27
|
const response = await client.pathUnchecked(path).post(httpRequestOptions);
|
|
30
28
|
|
|
31
29
|
if (typeof options?.operationOptions?.onResponse === "function") {
|
|
32
30
|
options?.operationOptions?.onResponse(response);
|
|
33
31
|
}
|
|
34
|
-
|
|
35
32
|
if (+response.status === 204 && !response.body) {
|
|
36
33
|
return;
|
|
37
34
|
}
|
|
38
|
-
|
|
39
35
|
throw createRestError(response);
|
|
40
36
|
}
|
|
41
37
|
```
|
|
@@ -47,7 +43,6 @@ export function jsonBodyModelToTransportTransform(input_?: BodyModel | null): an
|
|
|
47
43
|
if (!input_) {
|
|
48
44
|
return input_ as any;
|
|
49
45
|
}
|
|
50
|
-
|
|
51
46
|
return {
|
|
52
47
|
name: input_.name,
|
|
53
48
|
}!;
|
|
@@ -39,21 +39,17 @@ export async function read(
|
|
|
39
39
|
const path = parse("/widgets/{id}").expand({
|
|
40
40
|
id: id,
|
|
41
41
|
});
|
|
42
|
-
|
|
43
42
|
const httpRequestOptions = {
|
|
44
43
|
headers: {},
|
|
45
44
|
};
|
|
46
|
-
|
|
47
45
|
const response = await client.pathUnchecked(path).get(httpRequestOptions);
|
|
48
46
|
|
|
49
47
|
if (typeof options?.operationOptions?.onResponse === "function") {
|
|
50
48
|
options?.operationOptions?.onResponse(response);
|
|
51
49
|
}
|
|
52
|
-
|
|
53
50
|
if (+response.status === 204 && !response.body) {
|
|
54
51
|
return;
|
|
55
52
|
}
|
|
56
|
-
|
|
57
53
|
throw createRestError(response);
|
|
58
54
|
}
|
|
59
55
|
```
|
|
@@ -34,21 +34,17 @@ export async function read(
|
|
|
34
34
|
const path = parse("/widgets/{id}").expand({
|
|
35
35
|
id: id,
|
|
36
36
|
});
|
|
37
|
-
|
|
38
37
|
const httpRequestOptions = {
|
|
39
38
|
headers: {},
|
|
40
39
|
};
|
|
41
|
-
|
|
42
40
|
const response = await client.pathUnchecked(path).get(httpRequestOptions);
|
|
43
41
|
|
|
44
42
|
if (typeof options?.operationOptions?.onResponse === "function") {
|
|
45
43
|
options?.operationOptions?.onResponse(response);
|
|
46
44
|
}
|
|
47
|
-
|
|
48
45
|
if (+response.status === 204 && !response.body) {
|
|
49
46
|
return;
|
|
50
47
|
}
|
|
51
|
-
|
|
52
48
|
throw createRestError(response);
|
|
53
49
|
}
|
|
54
50
|
```
|
|
@@ -32,22 +32,18 @@ export async function create(
|
|
|
32
32
|
options?: CreateOptions,
|
|
33
33
|
): Promise<void> {
|
|
34
34
|
const path = parse("/widgets").expand({});
|
|
35
|
-
|
|
36
35
|
const httpRequestOptions = {
|
|
37
36
|
headers: {},
|
|
38
37
|
body: count,
|
|
39
38
|
};
|
|
40
|
-
|
|
41
39
|
const response = await client.pathUnchecked(path).post(httpRequestOptions);
|
|
42
40
|
|
|
43
41
|
if (typeof options?.operationOptions?.onResponse === "function") {
|
|
44
42
|
options?.operationOptions?.onResponse(response);
|
|
45
43
|
}
|
|
46
|
-
|
|
47
44
|
if (+response.status === 204 && !response.body) {
|
|
48
45
|
return;
|
|
49
46
|
}
|
|
50
|
-
|
|
51
47
|
throw createRestError(response);
|
|
52
48
|
}
|
|
53
49
|
```
|