@typespec/http-client-js 0.2.0-dev.2 → 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 +4 -4
- 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
|
@@ -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
|
```
|
|
@@ -43,7 +43,6 @@ export async function read(
|
|
|
43
43
|
id: id,
|
|
44
44
|
foo: foo,
|
|
45
45
|
});
|
|
46
|
-
|
|
47
46
|
const httpRequestOptions = {
|
|
48
47
|
headers: {
|
|
49
48
|
etag: etag,
|
|
@@ -52,17 +51,14 @@ export async function read(
|
|
|
52
51
|
name: name,
|
|
53
52
|
},
|
|
54
53
|
};
|
|
55
|
-
|
|
56
54
|
const response = await client.pathUnchecked(path).post(httpRequestOptions);
|
|
57
55
|
|
|
58
56
|
if (typeof options?.operationOptions?.onResponse === "function") {
|
|
59
57
|
options?.operationOptions?.onResponse(response);
|
|
60
58
|
}
|
|
61
|
-
|
|
62
59
|
if (+response.status === 204 && !response.body) {
|
|
63
60
|
return;
|
|
64
61
|
}
|
|
65
|
-
|
|
66
62
|
throw createRestError(response);
|
|
67
63
|
}
|
|
68
64
|
```
|
|
@@ -74,7 +70,6 @@ It should generate the client class with the read operation that calls the opera
|
|
|
74
70
|
```ts src/demoServiceClient.ts class WidgetsClient
|
|
75
71
|
export class WidgetsClient {
|
|
76
72
|
#context: WidgetsClientContext;
|
|
77
|
-
|
|
78
73
|
constructor(endpoint: string, options?: WidgetsClientOptions) {
|
|
79
74
|
this.#context = createWidgetsClientContext(endpoint, options);
|
|
80
75
|
}
|
|
@@ -42,21 +42,17 @@ export async function getModel(
|
|
|
42
42
|
options?: GetModelOptions,
|
|
43
43
|
): Promise<Fish> {
|
|
44
44
|
const path = parse("/").expand({});
|
|
45
|
-
|
|
46
45
|
const httpRequestOptions = {
|
|
47
46
|
headers: {},
|
|
48
47
|
};
|
|
49
|
-
|
|
50
48
|
const response = await client.pathUnchecked(path).get(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 === 200 && response.headers["content-type"]?.includes("application/json")) {
|
|
57
54
|
return jsonFishToApplicationTransform(response.body)!;
|
|
58
55
|
}
|
|
59
|
-
|
|
60
56
|
throw createRestError(response);
|
|
61
57
|
}
|
|
62
58
|
```
|
|
@@ -127,7 +123,6 @@ export function dateUnixTimestampDeserializer(date?: number | null): Date {
|
|
|
127
123
|
|
|
128
124
|
return new Date(date * 1000);
|
|
129
125
|
}
|
|
130
|
-
|
|
131
126
|
export function jsonFishToTransportDiscriminator(input_?: Fish): any {
|
|
132
127
|
if (!input_) {
|
|
133
128
|
return input_ as any;
|
|
@@ -147,14 +142,12 @@ export function jsonFishToTransportTransform(input_?: Fish | null): any {
|
|
|
147
142
|
if (!input_) {
|
|
148
143
|
return input_ as any;
|
|
149
144
|
}
|
|
150
|
-
|
|
151
145
|
return {
|
|
152
146
|
...jsonFishToTransportDiscriminator(input_),
|
|
153
147
|
age: input_.age,
|
|
154
148
|
kind: input_.kind,
|
|
155
149
|
}!;
|
|
156
150
|
}
|
|
157
|
-
|
|
158
151
|
export function jsonFishToApplicationDiscriminator(input_?: any): Fish {
|
|
159
152
|
if (!input_) {
|
|
160
153
|
return input_ as any;
|
|
@@ -174,14 +167,12 @@ export function jsonFishToApplicationTransform(input_?: any): Fish {
|
|
|
174
167
|
if (!input_) {
|
|
175
168
|
return input_ as any;
|
|
176
169
|
}
|
|
177
|
-
|
|
178
170
|
return {
|
|
179
171
|
...jsonFishToApplicationDiscriminator(input_),
|
|
180
172
|
age: input_.age,
|
|
181
173
|
kind: input_.kind,
|
|
182
174
|
}!;
|
|
183
175
|
}
|
|
184
|
-
|
|
185
176
|
export function jsonSharkToTransportDiscriminator(input_?: Shark): any {
|
|
186
177
|
if (!input_) {
|
|
187
178
|
return input_ as any;
|
|
@@ -201,7 +192,6 @@ export function jsonSharkToTransportTransform(input_?: Shark | null): any {
|
|
|
201
192
|
if (!input_) {
|
|
202
193
|
return input_ as any;
|
|
203
194
|
}
|
|
204
|
-
|
|
205
195
|
return {
|
|
206
196
|
...jsonSharkToTransportDiscriminator(input_),
|
|
207
197
|
kind: input_.kind,
|
|
@@ -209,7 +199,6 @@ export function jsonSharkToTransportTransform(input_?: Shark | null): any {
|
|
|
209
199
|
age: input_.age,
|
|
210
200
|
}!;
|
|
211
201
|
}
|
|
212
|
-
|
|
213
202
|
export function jsonSharkToApplicationDiscriminator(input_?: any): Shark {
|
|
214
203
|
if (!input_) {
|
|
215
204
|
return input_ as any;
|
|
@@ -229,7 +218,6 @@ export function jsonSharkToApplicationTransform(input_?: any): Shark {
|
|
|
229
218
|
if (!input_) {
|
|
230
219
|
return input_ as any;
|
|
231
220
|
}
|
|
232
|
-
|
|
233
221
|
return {
|
|
234
222
|
...jsonSharkToApplicationDiscriminator(input_),
|
|
235
223
|
kind: input_.kind,
|
|
@@ -237,60 +225,50 @@ export function jsonSharkToApplicationTransform(input_?: any): Shark {
|
|
|
237
225
|
age: input_.age,
|
|
238
226
|
}!;
|
|
239
227
|
}
|
|
240
|
-
|
|
241
228
|
export function jsonSawSharkToTransportTransform(input_?: SawShark | null): any {
|
|
242
229
|
if (!input_) {
|
|
243
230
|
return input_ as any;
|
|
244
231
|
}
|
|
245
|
-
|
|
246
232
|
return {
|
|
247
233
|
sharktype: input_.sharktype,
|
|
248
234
|
kind: input_.kind,
|
|
249
235
|
age: input_.age,
|
|
250
236
|
}!;
|
|
251
237
|
}
|
|
252
|
-
|
|
253
238
|
export function jsonSawSharkToApplicationTransform(input_?: any): SawShark {
|
|
254
239
|
if (!input_) {
|
|
255
240
|
return input_ as any;
|
|
256
241
|
}
|
|
257
|
-
|
|
258
242
|
return {
|
|
259
243
|
sharktype: input_.sharktype,
|
|
260
244
|
kind: input_.kind,
|
|
261
245
|
age: input_.age,
|
|
262
246
|
}!;
|
|
263
247
|
}
|
|
264
|
-
|
|
265
248
|
export function jsonGoblinSharkToTransportTransform(input_?: GoblinShark | null): any {
|
|
266
249
|
if (!input_) {
|
|
267
250
|
return input_ as any;
|
|
268
251
|
}
|
|
269
|
-
|
|
270
252
|
return {
|
|
271
253
|
sharktype: input_.sharktype,
|
|
272
254
|
kind: input_.kind,
|
|
273
255
|
age: input_.age,
|
|
274
256
|
}!;
|
|
275
257
|
}
|
|
276
|
-
|
|
277
258
|
export function jsonGoblinSharkToApplicationTransform(input_?: any): GoblinShark {
|
|
278
259
|
if (!input_) {
|
|
279
260
|
return input_ as any;
|
|
280
261
|
}
|
|
281
|
-
|
|
282
262
|
return {
|
|
283
263
|
sharktype: input_.sharktype,
|
|
284
264
|
kind: input_.kind,
|
|
285
265
|
age: input_.age,
|
|
286
266
|
}!;
|
|
287
267
|
}
|
|
288
|
-
|
|
289
268
|
export function jsonSalmonToTransportTransform(input_?: Salmon | null): any {
|
|
290
269
|
if (!input_) {
|
|
291
270
|
return input_ as any;
|
|
292
271
|
}
|
|
293
|
-
|
|
294
272
|
return {
|
|
295
273
|
kind: input_.kind,
|
|
296
274
|
friends: jsonArrayFishToTransportTransform(input_.friends),
|
|
@@ -299,12 +277,10 @@ export function jsonSalmonToTransportTransform(input_?: Salmon | null): any {
|
|
|
299
277
|
age: input_.age,
|
|
300
278
|
}!;
|
|
301
279
|
}
|
|
302
|
-
|
|
303
280
|
export function jsonSalmonToApplicationTransform(input_?: any): Salmon {
|
|
304
281
|
if (!input_) {
|
|
305
282
|
return input_ as any;
|
|
306
283
|
}
|
|
307
|
-
|
|
308
284
|
return {
|
|
309
285
|
kind: input_.kind,
|
|
310
286
|
friends: jsonArrayFishToApplicationTransform(input_.friends),
|