@typespec/http-client-js 0.16.2-dev.1 → 0.16.2
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/tsconfig.tsbuildinfo +1 -1
- package/package.json +24 -20
- package/.github/copilot-instructions.md +0 -180
- package/.testignore +0 -19
- package/.turbo/turbo-build.log +0 -3
- package/CHANGELOG.md +0 -159
- package/eng/scripts/calculate-coverage.ts +0 -33
- package/eng/scripts/emit-e2e.ts +0 -317
- package/eng/scripts/run-e2e-tests.ts +0 -166
- package/eng/scripts/tspconfig.yaml +0 -6
- package/eng/scripts/upload-spector-results.ts +0 -139
- package/src/components/client-context/client-context-declaration.tsx +0 -26
- package/src/components/client-context/client-context-factory.tsx +0 -218
- package/src/components/client-context/client-context-options.tsx +0 -36
- package/src/components/client-context/client-context.tsx +0 -23
- package/src/components/client-context/parametrized-endpoint.tsx +0 -51
- package/src/components/client-directory.tsx +0 -51
- package/src/components/client-operation.tsx +0 -102
- package/src/components/client.tsx +0 -177
- package/src/components/encoding-provider.tsx +0 -17
- package/src/components/external-packages/ts-http-runtime.ts +0 -28
- package/src/components/external-packages/uri-template.ts +0 -11
- package/src/components/http-request-options.tsx +0 -88
- package/src/components/http-request-parameters-expression.tsx +0 -191
- package/src/components/http-request.tsx +0 -80
- package/src/components/http-response.tsx +0 -74
- package/src/components/index.ts +0 -12
- package/src/components/models.tsx +0 -26
- package/src/components/operation-handlers/index.tsx +0 -2
- package/src/components/operation-handlers/operation-pipeline.tsx +0 -33
- package/src/components/operation-handlers/paging/page-item.tsx +0 -14
- package/src/components/operation-handlers/paging/page-response.tsx +0 -57
- package/src/components/operation-handlers/paging/page-settings.tsx +0 -53
- package/src/components/operation-handlers/paging/paginated-operation-handler.tsx +0 -200
- package/src/components/operation-handlers/paging/request-send.tsx +0 -85
- package/src/components/operation-handlers/paging/response-deserialize.tsx +0 -60
- package/src/components/operation-handlers/paging/util.ts +0 -70
- package/src/components/operation-handlers/types.tsx +0 -18
- package/src/components/operation-options.tsx +0 -42
- package/src/components/operation-parameters.tsx +0 -44
- package/src/components/output.tsx +0 -32
- package/src/components/serializers.tsx +0 -74
- package/src/components/static-helpers/bytes-encoding.tsx +0 -61
- package/src/components/static-helpers/interfaces.tsx +0 -31
- package/src/components/static-helpers/multipart-helpers.tsx +0 -80
- package/src/components/static-helpers/paging-helper.tsx +0 -202
- package/src/components/static-helpers/rest-error.tsx +0 -102
- package/src/components/testing/client-options.tsx +0 -30
- package/src/components/transforms/content-type-encoding-provider.tsx +0 -26
- package/src/components/transforms/data-transform.tsx +0 -40
- package/src/components/transforms/json/json-array-transform.tsx +0 -87
- package/src/components/transforms/json/json-model-additional-properties-transform.tsx +0 -54
- package/src/components/transforms/json/json-model-base-transform.tsx +0 -24
- package/src/components/transforms/json/json-model-property-transform.tsx +0 -53
- package/src/components/transforms/json/json-model-transform.tsx +0 -115
- package/src/components/transforms/json/json-record-transform.tsx +0 -88
- package/src/components/transforms/json/json-transform-discriminator.tsx +0 -111
- package/src/components/transforms/json/json-transform.tsx +0 -120
- package/src/components/transforms/json/union-transform.tsx +0 -87
- package/src/components/transforms/json/utils/transport-namer.ts +0 -12
- package/src/components/transforms/multipart/array-part-transform.tsx +0 -44
- package/src/components/transforms/multipart/file-part-transform.tsx +0 -45
- package/src/components/transforms/multipart/multipart-transform.tsx +0 -30
- package/src/components/transforms/multipart/part-transform.tsx +0 -22
- package/src/components/transforms/multipart/simple-part-transform.tsx +0 -42
- package/src/components/transforms/operation-transform-declaration.tsx +0 -83
- package/src/components/transforms/operation-transform-expression.tsx +0 -62
- package/src/components/transforms/scalar-transform.tsx +0 -301
- package/src/components/transforms/transform-name-policy.ts +0 -134
- package/src/components/utils/unpack-model-property.ts +0 -44
- package/src/components/utils/url-template.tsx +0 -25
- package/src/context/encoding/encoding-context.tsx +0 -28
- package/src/context/encoding/types.ts +0 -6
- package/src/emitter.tsx +0 -85
- package/src/index.ts +0 -5
- package/src/lib.ts +0 -120
- package/src/testing/index.ts +0 -11
- package/src/utils/client-discovery.ts +0 -28
- package/src/utils/multipart.ts +0 -29
- package/src/utils/operations.ts +0 -112
- package/src/utils/parameters.tsx +0 -155
- package/test/e2e/assets/image.jpg +0 -0
- package/test/e2e/assets/image.png +0 -0
- package/test/e2e/http/authentication/api-key/main.test.ts +0 -38
- package/test/e2e/http/authentication/oauth2/main.test.ts +0 -31
- package/test/e2e/http/authentication/union/main.test.ts +0 -26
- package/test/e2e/http/encode/bytes/main.test.ts +0 -191
- package/test/e2e/http/encode/datetime/main.test.ts +0 -176
- package/test/e2e/http/encode/duration/main.test.ts +0 -126
- package/test/e2e/http/encode/numeric/main.test.ts +0 -26
- package/test/e2e/http/parameters/basic/main.test.ts +0 -35
- package/test/e2e/http/parameters/body-optionality/main.test.ts +0 -43
- package/test/e2e/http/parameters/collection-format/main.test.ts +0 -40
- package/test/e2e/http/parameters/spread/main.test.ts +0 -56
- package/test/e2e/http/payload/content-negotiation/main.test.ts +0 -40
- package/test/e2e/http/payload/json-merge-patch/main.test.ts +0 -122
- package/test/e2e/http/payload/media-type/main.test.ts +0 -28
- package/test/e2e/http/payload/multipart/main.test.ts +0 -200
- package/test/e2e/http/payload/pageable/main.test.ts +0 -78
- package/test/e2e/http/payload/xml/main.test.ts +0 -287
- package/test/e2e/http/routes/main.test.ts +0 -284
- package/test/e2e/http/serialization/encoded-name/json/main.test.ts +0 -20
- package/test/e2e/http/server/endpoint/not-defined/main.test.ts +0 -11
- package/test/e2e/http/server/path/multiple/main.test.ts +0 -22
- package/test/e2e/http/server/path/single/main.test.ts +0 -11
- package/test/e2e/http/server/versions/not-versioned/main.test.ts +0 -22
- package/test/e2e/http/server/versions/versioned/main.test.ts +0 -28
- package/test/e2e/http/special-headers/conditional-request/main.test.ts +0 -35
- package/test/e2e/http/special-headers/repeatability/main.test.ts +0 -18
- package/test/e2e/http/special-words/main.test.ts +0 -434
- package/test/e2e/http/type/array/array.test.ts +0 -256
- package/test/e2e/http/type/dictionary/main.test.ts +0 -229
- package/test/e2e/http/type/enum/extensible/main.test.ts +0 -34
- package/test/e2e/http/type/enum/fixed/main.test.ts +0 -29
- package/test/e2e/http/type/model/empty/main.test.ts +0 -21
- package/test/e2e/http/type/model/inheritance/enum-discriminator/main.test.ts +0 -51
- package/test/e2e/http/type/model/inheritance/nested-discriminator/main.test.ts +0 -168
- package/test/e2e/http/type/model/inheritance/not-discriminated/main.test.ts +0 -42
- package/test/e2e/http/type/model/inheritance/recursive/main.test.ts +0 -46
- package/test/e2e/http/type/model/inheritance/single-discriminator/main.test.ts +0 -99
- package/test/e2e/http/type/model/visibility/main.test.ts +0 -64
- package/test/e2e/http/type/property/additional-properties/main.test.ts +0 -185
- package/test/e2e/http/type/property/additional-properties/spreads.test.ts +0 -448
- package/test/e2e/http/type/property/nullable/main.test.ts +0 -275
- package/test/e2e/http/type/property/optionality/main.test.ts +0 -256
- package/test/e2e/http/type/property/value-types/main.test.ts +0 -193
- package/test/e2e/http/type/scalar/main.test.ts +0 -133
- package/test/e2e/http/type/scalar/scalar.test.ts +0 -95
- package/test/e2e/http/type/union/main.test.ts +0 -207
- package/test/e2e/http/versioning/added/main.test.ts +0 -60
- package/test/e2e/http/versioning/madeOptional/main.test.ts +0 -34
- package/test/e2e/http/versioning/removed/main.test.ts +0 -75
- package/test/e2e/http/versioning/renamedFrom/main.test.ts +0 -52
- package/test/e2e/http/versioning/returnTypeChangedFrom/main.test.ts +0 -22
- package/test/e2e/http/versioning/typeChangedFrom/main.test.ts +0 -31
- package/test/scenarios/additional-properties/extends.md +0 -67
- package/test/scenarios/additional-properties/is.md +0 -42
- package/test/scenarios/additional-properties/spread.md +0 -68
- package/test/scenarios/auth/basic_auth.md +0 -68
- package/test/scenarios/auth/bearer.md +0 -68
- package/test/scenarios/auth/client_parameters.md +0 -78
- package/test/scenarios/auth/client_structure.md +0 -36
- package/test/scenarios/auth/key_credential.md +0 -69
- package/test/scenarios/auth/oauth2.md +0 -90
- package/test/scenarios/auth/sub_client_override.md +0 -114
- package/test/scenarios/client/client_context.md +0 -34
- package/test/scenarios/client/dotted_namespace.md +0 -27
- package/test/scenarios/client/global_namespace.md +0 -69
- package/test/scenarios/client/multiple_top_level_clients.md +0 -72
- package/test/scenarios/client/nested_client.md +0 -102
- package/test/scenarios/client/wrapping_namespace.md +0 -41
- package/test/scenarios/encoding/bytes_body.md +0 -44
- package/test/scenarios/encoding/bytes_json_property.md +0 -55
- package/test/scenarios/encoding/bytes_nullable.md +0 -139
- package/test/scenarios/encoding/header_bytes.md +0 -130
- package/test/scenarios/encoding/header_date.md +0 -216
- package/test/scenarios/encoding/model_with_bytes_property.md +0 -45
- package/test/scenarios/encoding/query_bytes.md +0 -42
- package/test/scenarios/encoding/query_date.md +0 -216
- package/test/scenarios/http-operations/basic-request.md +0 -144
- package/test/scenarios/http-operations/basic-response.md +0 -219
- package/test/scenarios/http-operations/basic.md +0 -128
- package/test/scenarios/http-operations/constant-header.md +0 -33
- package/test/scenarios/http-operations/create-operation.md +0 -58
- package/test/scenarios/http-operations/on_response.md +0 -52
- package/test/scenarios/http-operations/optional-request-body.md +0 -50
- package/test/scenarios/http-operations/paging.md +0 -242
- package/test/scenarios/http-operations/path-parameter-in-model.md +0 -53
- package/test/scenarios/http-operations/path-parameter.md +0 -48
- package/test/scenarios/http-operations/query-parameter.md +0 -41
- package/test/scenarios/http-operations/scalar-payload.md +0 -57
- package/test/scenarios/http-operations/with-parameters.md +0 -78
- package/test/scenarios/models/array-properties.md +0 -47
- package/test/scenarios/models/basic.md +0 -118
- package/test/scenarios/models/dictionary-properties.md +0 -44
- package/test/scenarios/models/inheritance_2_discriminators.md +0 -346
- package/test/scenarios/models/inheritance_discriminator.md +0 -88
- package/test/scenarios/models/inline-models.md +0 -29
- package/test/scenarios/models/model_additional_properties.md +0 -75
- package/test/scenarios/models/model_extends.md +0 -97
- package/test/scenarios/models/model_spread.md +0 -63
- package/test/scenarios/models/nested_property.md +0 -41
- package/test/scenarios/models/property_references_property.md +0 -150
- package/test/scenarios/multipart/anonymous_part.md +0 -53
- package/test/scenarios/multipart/file.md +0 -154
- package/test/scenarios/multipart/file_content_type.md +0 -92
- package/test/scenarios/multipart/non-string-float.md +0 -55
- package/test/scenarios/multipart/simple_part.md +0 -65
- package/test/scenarios/operation-parameters/body_root_anonymous.md +0 -87
- package/test/scenarios/operation-parameters/constant_as_optional.md +0 -54
- package/test/scenarios/operation-parameters/default_value_as_optional.md +0 -54
- package/test/scenarios/operation-parameters/no_content_type.md +0 -62
- package/test/scenarios/operation-parameters/no_parameters.md +0 -50
- package/test/scenarios/operation-parameters/only_optional.md +0 -62
- package/test/scenarios/operation-parameters/only_required.md +0 -58
- package/test/scenarios/operation-parameters/reserved_names.md +0 -60
- package/test/scenarios/operation-parameters/spread_body.md +0 -70
- package/test/scenarios/operation-parameters/spread_with_nested.md +0 -82
- package/test/scenarios/operation-parameters/union_body.md +0 -86
- package/test/scenarios/operation-parameters/with_body_property.md +0 -67
- package/test/scenarios/operation-parameters/with_body_root.md +0 -69
- package/test/scenarios/serializers/arrays.md +0 -191
- package/test/scenarios/serializers/basic_model.md +0 -111
- package/test/scenarios/serializers/basic_model_wire_name.md +0 -48
- package/test/scenarios/serializers/discriminated_union.md +0 -86
- package/test/scenarios/serializers/discriminated_union_spread.md +0 -115
- package/test/scenarios/serializers/file.md +0 -67
- package/test/scenarios/serializers/model_date_time.md +0 -65
- package/test/scenarios/serializers/multipart.md +0 -62
- package/test/scenarios/serializers/polymorphic_single_level_inheritance.md +0 -157
- package/test/scenarios/serializers/property_references_property.md +0 -72
- package/test/scenarios/serializers/record.md +0 -97
- package/test/scenarios/serializers/scalars.md +0 -34
- package/test/scenarios/serializers/spread.md +0 -69
- package/test/scenarios/serializers/string_union.md +0 -55
- package/test/scenarios/server/default_url.md +0 -45
- package/test/scenarios/server/multiple-parameters.md +0 -55
- package/test/scenarios/server/no-server.md +0 -37
- package/test/scenarios/server/parametrized-endpoint.md +0 -51
- package/test/scenarios.test.ts +0 -24
- package/test/test-host.ts +0 -22
- package/tsconfig.json +0 -16
- package/tsconfig.test.json +0 -9
- package/vitest.config.e2e.ts +0 -16
- package/vitest.config.ts +0 -15
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
# Should generate the correct properties and handle deserialization for models with different client than wire names
|
|
2
|
-
|
|
3
|
-
## TypeSpec
|
|
4
|
-
|
|
5
|
-
```tsp
|
|
6
|
-
model Foo {
|
|
7
|
-
element_name: string;
|
|
8
|
-
age: int32;
|
|
9
|
-
}
|
|
10
|
-
op foo(): Foo;
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## TypeScript
|
|
14
|
-
|
|
15
|
-
Should generate a type for type with name `Foo` in the `src/models/models.ts` file along with a serializer named `jsonFooToTransportTransform` and a deserializer named `jsonFooToApplicationTransform` in `src/models/internal/serializers.ts`.
|
|
16
|
-
The generated model should have property names using camelCasing. Serializer should return these properties with the same name defined in the spec while the deserializer
|
|
17
|
-
should return these properties with the same name as the generated model (camelCase)
|
|
18
|
-
|
|
19
|
-
```ts src/models/models.ts interface Foo
|
|
20
|
-
export interface Foo {
|
|
21
|
-
elementName: string;
|
|
22
|
-
age: number;
|
|
23
|
-
}
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
```ts src/models/internal/serializers.ts function jsonFooToTransportTransform
|
|
27
|
-
export function jsonFooToTransportTransform(input_?: Foo | null): any {
|
|
28
|
-
if (!input_) {
|
|
29
|
-
return input_ as any;
|
|
30
|
-
}
|
|
31
|
-
return {
|
|
32
|
-
element_name: input_.elementName,
|
|
33
|
-
age: input_.age,
|
|
34
|
-
}!;
|
|
35
|
-
}
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
```ts src/models/internal/serializers.ts function jsonFooToApplicationTransform
|
|
39
|
-
export function jsonFooToApplicationTransform(input_?: any): Foo {
|
|
40
|
-
if (!input_) {
|
|
41
|
-
return input_ as any;
|
|
42
|
-
}
|
|
43
|
-
return {
|
|
44
|
-
elementName: input_.element_name,
|
|
45
|
-
age: input_.age,
|
|
46
|
-
}!;
|
|
47
|
-
}
|
|
48
|
-
```
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
# Should handle a discriminated union
|
|
2
|
-
|
|
3
|
-
## Typespec
|
|
4
|
-
|
|
5
|
-
```tsp
|
|
6
|
-
@service
|
|
7
|
-
namespace Test;
|
|
8
|
-
@discriminated(#{ envelope: "none", discriminatorPropertyName: "kind" })
|
|
9
|
-
union WidgetData {
|
|
10
|
-
kind0: WidgetData0,
|
|
11
|
-
kind1: WidgetData1,
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
model WidgetData0 {
|
|
15
|
-
kind: "kind0";
|
|
16
|
-
fooProp: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
model WidgetData1 {
|
|
20
|
-
kind: "kind1";
|
|
21
|
-
start: utcDateTime;
|
|
22
|
-
end?: utcDateTime;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
@get
|
|
26
|
-
op get(): WidgetData;
|
|
27
|
-
|
|
28
|
-
@put
|
|
29
|
-
op put(@body body: WidgetData): void;
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## Typescript
|
|
33
|
-
|
|
34
|
-
```ts src/models/internal/serializers.ts function jsonWidgetDataToTransportTransform
|
|
35
|
-
export function jsonWidgetDataToTransportTransform(input_?: WidgetData | null): any {
|
|
36
|
-
if (!input_) {
|
|
37
|
-
return input_ as any;
|
|
38
|
-
}
|
|
39
|
-
return jsonWidgetDataToTransportDiscriminator(input_);
|
|
40
|
-
}
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
```ts src/models/internal/serializers.ts function jsonWidgetDataToApplicationTransform
|
|
44
|
-
export function jsonWidgetDataToApplicationTransform(input_?: any): WidgetData {
|
|
45
|
-
if (!input_) {
|
|
46
|
-
return input_ as any;
|
|
47
|
-
}
|
|
48
|
-
return jsonWidgetDataToApplicationDiscriminator(input_);
|
|
49
|
-
}
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
```ts src/models/internal/serializers.ts function jsonWidgetDataToTransportDiscriminator
|
|
53
|
-
export function jsonWidgetDataToTransportDiscriminator(input_?: WidgetData): any {
|
|
54
|
-
if (!input_) {
|
|
55
|
-
return input_ as any;
|
|
56
|
-
}
|
|
57
|
-
const discriminatorValue = input_.kind;
|
|
58
|
-
if (discriminatorValue === "kind0") {
|
|
59
|
-
return jsonWidgetData0ToTransportTransform(input_ as any)!;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (discriminatorValue === "kind1") {
|
|
63
|
-
return jsonWidgetData1ToTransportTransform(input_ as any)!;
|
|
64
|
-
}
|
|
65
|
-
console.warn(`Received unknown kind: ` + discriminatorValue);
|
|
66
|
-
return input_ as any;
|
|
67
|
-
}
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
```ts src/models/internal/serializers.ts function jsonWidgetDataToApplicationDiscriminator
|
|
71
|
-
export function jsonWidgetDataToApplicationDiscriminator(input_?: any): WidgetData {
|
|
72
|
-
if (!input_) {
|
|
73
|
-
return input_ as any;
|
|
74
|
-
}
|
|
75
|
-
const discriminatorValue = input_.kind;
|
|
76
|
-
if (discriminatorValue === "kind0") {
|
|
77
|
-
return jsonWidgetData0ToApplicationTransform(input_ as any)!;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (discriminatorValue === "kind1") {
|
|
81
|
-
return jsonWidgetData1ToApplicationTransform(input_ as any)!;
|
|
82
|
-
}
|
|
83
|
-
console.warn(`Received unknown kind: ` + discriminatorValue);
|
|
84
|
-
return input_ as any;
|
|
85
|
-
}
|
|
86
|
-
```
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
# Should handle a discriminated union
|
|
2
|
-
|
|
3
|
-
## Typespec
|
|
4
|
-
|
|
5
|
-
```tsp
|
|
6
|
-
@service
|
|
7
|
-
namespace Test;
|
|
8
|
-
@discriminated(#{ envelope: "none", discriminatorPropertyName: "kind" })
|
|
9
|
-
union WidgetData {
|
|
10
|
-
kind0: WidgetData0,
|
|
11
|
-
kind1: WidgetData1,
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
model WidgetData0 {
|
|
15
|
-
kind: "kind0";
|
|
16
|
-
fooProp: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
model WidgetData1 {
|
|
20
|
-
kind: "kind1";
|
|
21
|
-
start: utcDateTime;
|
|
22
|
-
end?: utcDateTime;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
@doc("The model spread Record<WidgetData>")
|
|
26
|
-
model SpreadRecordForDiscriminatedUnion {
|
|
27
|
-
@doc("The name property")
|
|
28
|
-
name: string;
|
|
29
|
-
|
|
30
|
-
...Record<WidgetData>;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
@get
|
|
34
|
-
op get(): SpreadRecordForDiscriminatedUnion;
|
|
35
|
-
|
|
36
|
-
@put
|
|
37
|
-
op put(@body body: SpreadRecordForDiscriminatedUnion): void;
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
## Typescript
|
|
41
|
-
|
|
42
|
-
```ts src/models/internal/serializers.ts function jsonSpreadRecordForDiscriminatedUnionToTransportTransform
|
|
43
|
-
export function jsonSpreadRecordForDiscriminatedUnionToTransportTransform(
|
|
44
|
-
input_?: SpreadRecordForDiscriminatedUnion | null,
|
|
45
|
-
): any {
|
|
46
|
-
if (!input_) {
|
|
47
|
-
return input_ as any;
|
|
48
|
-
}
|
|
49
|
-
return {
|
|
50
|
-
...jsonRecordWidgetDataToTransportTransform(input_.additionalProperties),
|
|
51
|
-
name: input_.name,
|
|
52
|
-
}!;
|
|
53
|
-
}
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
```ts src/models/internal/serializers.ts function jsonSpreadRecordForDiscriminatedUnionToApplicationTransform
|
|
57
|
-
export function jsonSpreadRecordForDiscriminatedUnionToApplicationTransform(
|
|
58
|
-
input_?: any,
|
|
59
|
-
): SpreadRecordForDiscriminatedUnion {
|
|
60
|
-
if (!input_) {
|
|
61
|
-
return input_ as any;
|
|
62
|
-
}
|
|
63
|
-
return {
|
|
64
|
-
additionalProperties: jsonRecordWidgetDataToApplicationTransform(
|
|
65
|
-
(({ name, ...rest }) => rest)(input_),
|
|
66
|
-
),
|
|
67
|
-
name: input_.name,
|
|
68
|
-
}!;
|
|
69
|
-
}
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
```ts src/models/internal/serializers.ts function jsonWidgetDataToTransportTransform
|
|
73
|
-
export function jsonWidgetDataToTransportTransform(input_?: WidgetData | null): any {
|
|
74
|
-
if (!input_) {
|
|
75
|
-
return input_ as any;
|
|
76
|
-
}
|
|
77
|
-
return jsonWidgetDataToTransportDiscriminator(input_);
|
|
78
|
-
}
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
```ts src/models/internal/serializers.ts function jsonWidgetDataToApplicationDiscriminator
|
|
82
|
-
export function jsonWidgetDataToApplicationDiscriminator(input_?: any): WidgetData {
|
|
83
|
-
if (!input_) {
|
|
84
|
-
return input_ as any;
|
|
85
|
-
}
|
|
86
|
-
const discriminatorValue = input_.kind;
|
|
87
|
-
if (discriminatorValue === "kind0") {
|
|
88
|
-
return jsonWidgetData0ToApplicationTransform(input_ as any)!;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (discriminatorValue === "kind1") {
|
|
92
|
-
return jsonWidgetData1ToApplicationTransform(input_ as any)!;
|
|
93
|
-
}
|
|
94
|
-
console.warn(`Received unknown kind: ` + discriminatorValue);
|
|
95
|
-
return input_ as any;
|
|
96
|
-
}
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
```ts src/models/internal/serializers.ts function jsonWidgetDataToTransportDiscriminator
|
|
100
|
-
export function jsonWidgetDataToTransportDiscriminator(input_?: WidgetData): any {
|
|
101
|
-
if (!input_) {
|
|
102
|
-
return input_ as any;
|
|
103
|
-
}
|
|
104
|
-
const discriminatorValue = input_.kind;
|
|
105
|
-
if (discriminatorValue === "kind0") {
|
|
106
|
-
return jsonWidgetData0ToTransportTransform(input_ as any)!;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (discriminatorValue === "kind1") {
|
|
110
|
-
return jsonWidgetData1ToTransportTransform(input_ as any)!;
|
|
111
|
-
}
|
|
112
|
-
console.warn(`Received unknown kind: ` + discriminatorValue);
|
|
113
|
-
return input_ as any;
|
|
114
|
-
}
|
|
115
|
-
```
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
# Should handle File Parts
|
|
2
|
-
|
|
3
|
-
```tsp
|
|
4
|
-
namespace Test;
|
|
5
|
-
|
|
6
|
-
model FileSpecificContentType extends File {
|
|
7
|
-
filename: string;
|
|
8
|
-
contentType: "image/jpg";
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
model FileWithHttpPartSpecificContentTypeRequest {
|
|
12
|
-
profileImage: HttpPart<FileSpecificContentType>;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
@post
|
|
16
|
-
op imageJpegContentType(
|
|
17
|
-
@header contentType: "multipart/form-data",
|
|
18
|
-
@multipartBody body: FileWithHttpPartSpecificContentTypeRequest,
|
|
19
|
-
): NoContentResponse;
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
## Serializers
|
|
23
|
-
|
|
24
|
-
```ts src/models/internal/serializers.ts function jsonFileSpecificContentTypeToApplicationTransform
|
|
25
|
-
export function jsonFileSpecificContentTypeToApplicationTransform(
|
|
26
|
-
input_?: any,
|
|
27
|
-
): FileSpecificContentType {
|
|
28
|
-
if (!input_) {
|
|
29
|
-
return input_ as any;
|
|
30
|
-
}
|
|
31
|
-
return {
|
|
32
|
-
filename: input_.filename,
|
|
33
|
-
contentType: input_.contentType,
|
|
34
|
-
contents: input_.contents,
|
|
35
|
-
}!;
|
|
36
|
-
}
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
```ts src/models/internal/serializers.ts function jsonFileSpecificContentTypeToTransportTransform
|
|
40
|
-
export function jsonFileSpecificContentTypeToTransportTransform(
|
|
41
|
-
input_?: FileSpecificContentType | null,
|
|
42
|
-
): any {
|
|
43
|
-
if (!input_) {
|
|
44
|
-
return input_ as any;
|
|
45
|
-
}
|
|
46
|
-
return {
|
|
47
|
-
filename: input_.filename,
|
|
48
|
-
contentType: input_.contentType,
|
|
49
|
-
contents: input_.contents,
|
|
50
|
-
}!;
|
|
51
|
-
}
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
It shouldn't try to base64 encode the contents
|
|
55
|
-
|
|
56
|
-
```ts src/models/internal/serializers.ts function jsonFileToTransportTransform
|
|
57
|
-
export function jsonFileToTransportTransform(input_?: File | null): any {
|
|
58
|
-
if (!input_) {
|
|
59
|
-
return input_ as any;
|
|
60
|
-
}
|
|
61
|
-
return {
|
|
62
|
-
contentType: input_.contentType,
|
|
63
|
-
filename: input_.filename,
|
|
64
|
-
contents: input_.contents,
|
|
65
|
-
}!;
|
|
66
|
-
}
|
|
67
|
-
```
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
# skip:Should generate the correct properties and handle deserialization for models with utcDateTime type
|
|
2
|
-
|
|
3
|
-
Defaults to rfc7231 encoding
|
|
4
|
-
|
|
5
|
-
## TypeSpec
|
|
6
|
-
|
|
7
|
-
```tsp
|
|
8
|
-
model Foo {
|
|
9
|
-
created_on: utcDateTime;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
op foo(): Foo;
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## TypeScript
|
|
16
|
-
|
|
17
|
-
Should generate a type for type with name `Foo` in the `src/models/models.ts` file along with a serializer named `jsonFooToTransportTransform` and a deserializer named `jsonFooToApplicationTransform` in `src/models/internal/serializers.ts`.
|
|
18
|
-
The generated model should have a property `createdOn` of type `Date`, the generated serializer `jsonFooToTransportTransform` should convert a Date into a string.
|
|
19
|
-
|
|
20
|
-
```ts src/models/models.ts interface Foo
|
|
21
|
-
export interface Foo {
|
|
22
|
-
createdOn: Date;
|
|
23
|
-
}
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
```ts src/models/internal/serializers.ts function jsonFooToTransportTransform
|
|
27
|
-
export function jsonFooToTransportTransform(item: Foo): any {
|
|
28
|
-
return {
|
|
29
|
-
created_on: dateRfc3339Serializer(item.createdOn),
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
```ts src/models/internal/serializers.ts function jsonFooToApplicationTransform
|
|
35
|
-
export function jsonFooToApplicationTransform(item: any): Foo {
|
|
36
|
-
return {
|
|
37
|
-
createdOn: dateDeserializer(item.created_on),
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
# skip:Should generate the correct properties and handle deserialization for models with utcDateTime type with rfc7231 encoding
|
|
43
|
-
|
|
44
|
-
## TypeSpec
|
|
45
|
-
|
|
46
|
-
```tsp
|
|
47
|
-
model Foo {
|
|
48
|
-
@encode("rfc7231")
|
|
49
|
-
created_on: utcDateTime;
|
|
50
|
-
}
|
|
51
|
-
op foo(): Foo;
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
## TypeScript
|
|
55
|
-
|
|
56
|
-
Should generate a type for type with name `Foo` in the `src/models/models.ts` file along with a serializer named `jsonFooToTransportTransform` and a deserializer named `jsonFooToApplicationTransform` in `src/models/internal/serializers.ts`.
|
|
57
|
-
The generated model should have a property `createdOn` of type `Date`, the generated serializer `jsonFooToTransportTransform` should convert a Date into a string using `toUTCString()`
|
|
58
|
-
|
|
59
|
-
```ts src/models/internal/serializers.ts function jsonFooToTransportTransform
|
|
60
|
-
export function jsonFooToTransportTransform(item: Foo): any {
|
|
61
|
-
return {
|
|
62
|
-
created_on: dateRfc7231Serializer(item.createdOn),
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
```
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
# Should emit serializer and deserializer correctly for properties with primitive array type
|
|
2
|
-
|
|
3
|
-
## Typespec
|
|
4
|
-
|
|
5
|
-
```tsp
|
|
6
|
-
namespace Test;
|
|
7
|
-
model FileSpecificContentType extends File {
|
|
8
|
-
filename: string;
|
|
9
|
-
contentType: "image/jpg";
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
model FileWithHttpPartSpecificContentTypeRequest {
|
|
13
|
-
profileImage: HttpPart<FileSpecificContentType>;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
@post op create(
|
|
17
|
-
@header contentType: "multipart/form-data",
|
|
18
|
-
@multipartBody body: FileWithHttpPartSpecificContentTypeRequest,
|
|
19
|
-
): NoContentResponse;
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
## TypeScript
|
|
23
|
-
|
|
24
|
-
Should generate a model `FileWithHttpPartSpecificContentTypeRequest` and also a `fileWithHttpPartSpecificContentTypeRequestToTransport` and `fileWithHttpPartSpecificContentTypeRequestToApplication`.
|
|
25
|
-
|
|
26
|
-
```ts src/models/models.ts interface FileSpecificContentType
|
|
27
|
-
export interface FileSpecificContentType extends File {
|
|
28
|
-
filename: string;
|
|
29
|
-
contentType: "image/jpg";
|
|
30
|
-
}
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
```ts src/models/models.ts interface FileWithHttpPartSpecificContentTypeRequest
|
|
34
|
-
export interface FileWithHttpPartSpecificContentTypeRequest {
|
|
35
|
-
profileImage: FileSpecificContentType;
|
|
36
|
-
}
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
```ts src/api/testClientOperations.ts function create
|
|
40
|
-
export async function create(
|
|
41
|
-
client: TestClientContext,
|
|
42
|
-
body: FileWithHttpPartSpecificContentTypeRequest,
|
|
43
|
-
options?: CreateOptions,
|
|
44
|
-
): Promise<void> {
|
|
45
|
-
const path = parse("/").expand({});
|
|
46
|
-
const httpRequestOptions = {
|
|
47
|
-
headers: {
|
|
48
|
-
"content-type": options?.contentType ?? "multipart/form-data",
|
|
49
|
-
},
|
|
50
|
-
body: [createFilePartDescriptor("profileImage", body.profileImage, "image/jpg")],
|
|
51
|
-
};
|
|
52
|
-
const response = await client.pathUnchecked(path).post(httpRequestOptions);
|
|
53
|
-
|
|
54
|
-
if (typeof options?.operationOptions?.onResponse === "function") {
|
|
55
|
-
options?.operationOptions?.onResponse(response);
|
|
56
|
-
}
|
|
57
|
-
if (+response.status === 204 && !response.body) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
throw createRestError(response);
|
|
61
|
-
}
|
|
62
|
-
```
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
# Should Emit Correct Serializers and Deserializers for Polymorphic Models with Records, Arrays, and References"
|
|
2
|
-
|
|
3
|
-
## Typespec
|
|
4
|
-
|
|
5
|
-
The following TypeSpec block defines a service and several data models that serve as the foundation for our serializer tests. It starts with a base model, Bird, which uses a discriminator (kind) to support polymorphic behavior. Several derived models—SeaGull, Sparrow, Goose, and Eagle—are declared, each with a specific kind value to enable precise runtime type dispatching. Notably, the Eagle model includes additional complex properties (an array, a record, and a singular instance of Bird) to thoroughly test serialization of nested and compound types. This specification also exposes an HTTP GET endpoint returning a polymorphic Bird instance, ensuring that the generated TypeScript serializers handle these scenarios correctly.
|
|
6
|
-
|
|
7
|
-
```tsp
|
|
8
|
-
@service(#{ title: "Test Service" })
|
|
9
|
-
namespace Test;
|
|
10
|
-
|
|
11
|
-
@doc("This is base model for polymorphic single level inheritance with a discriminator.")
|
|
12
|
-
@discriminator("kind")
|
|
13
|
-
model Bird {
|
|
14
|
-
kind: string;
|
|
15
|
-
wingspan: int32;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
@doc("The second level model in polymorphic single level inheritance.")
|
|
19
|
-
model SeaGull extends Bird {
|
|
20
|
-
kind: "seagull";
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
@doc("The second level model in polymorphic single level inheritance.")
|
|
24
|
-
model Sparrow extends Bird {
|
|
25
|
-
kind: "sparrow";
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
@doc("The second level model in polymorphic single level inheritance.")
|
|
29
|
-
model Goose extends Bird {
|
|
30
|
-
kind: "goose";
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
@doc("The second level model in polymorphic single levels inheritance which contains references to other polymorphic instances.")
|
|
34
|
-
model Eagle extends Bird {
|
|
35
|
-
kind: "eagle";
|
|
36
|
-
friends?: Bird[];
|
|
37
|
-
hate?: Record<Bird>;
|
|
38
|
-
partner?: Bird;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
@route("/model")
|
|
42
|
-
@get
|
|
43
|
-
op getModel(): Bird;
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
**Expectation for `jsonBirdToTransportDiscriminator`:**
|
|
47
|
-
This function should select the appropriate transport transformation based on the `kind` property of the `Bird` instance. It checks for specific kinds ("seagull", "sparrow", "goose", "eagle") and delegates to the corresponding transform. If the kind is unknown, it logs a warning and returns a fallback value.
|
|
48
|
-
|
|
49
|
-
```ts src/models/internal/serializers.ts function jsonBirdToTransportDiscriminator
|
|
50
|
-
export function jsonBirdToTransportDiscriminator(input_?: Bird): any {
|
|
51
|
-
if (!input_) {
|
|
52
|
-
return input_ as any;
|
|
53
|
-
}
|
|
54
|
-
const discriminatorValue = input_.kind;
|
|
55
|
-
if (discriminatorValue === "seagull") {
|
|
56
|
-
return jsonSeaGullToTransportTransform(input_ as any)!;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (discriminatorValue === "sparrow") {
|
|
60
|
-
return jsonSparrowToTransportTransform(input_ as any)!;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (discriminatorValue === "goose") {
|
|
64
|
-
return jsonGooseToTransportTransform(input_ as any)!;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (discriminatorValue === "eagle") {
|
|
68
|
-
return jsonEagleToTransportTransform(input_ as any)!;
|
|
69
|
-
}
|
|
70
|
-
console.warn(`Received unknown kind: ` + discriminatorValue);
|
|
71
|
-
return input_ as any;
|
|
72
|
-
}
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
**Expectation for `jsonBirdToTransportTransform`:**
|
|
76
|
-
This function should transform a basic `Bird` instance by mapping its core properties (`kind` and `wingspan`) to the transport format.
|
|
77
|
-
|
|
78
|
-
```ts src/models/internal/serializers.ts function jsonBirdToTransportTransform
|
|
79
|
-
export function jsonBirdToTransportTransform(input_?: Bird | null): any {
|
|
80
|
-
if (!input_) {
|
|
81
|
-
return input_ as any;
|
|
82
|
-
}
|
|
83
|
-
return {
|
|
84
|
-
...jsonBirdToTransportDiscriminator(input_),
|
|
85
|
-
kind: input_.kind,
|
|
86
|
-
wingspan: input_.wingspan,
|
|
87
|
-
}!;
|
|
88
|
-
}
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
**Expectation for `jsonSeaGullToTransportTransform`:**
|
|
92
|
-
For a `SeaGull` instance, the serializer should extend the base transformation provided by `jsonBirdToApplicationTransform` and then explicitly include all properties from SeaGull in this case it is just the `kind` .
|
|
93
|
-
|
|
94
|
-
```ts src/models/internal/serializers.ts function jsonSeaGullToTransportTransform
|
|
95
|
-
export function jsonSeaGullToTransportTransform(input_?: SeaGull | null): any {
|
|
96
|
-
if (!input_) {
|
|
97
|
-
return input_ as any;
|
|
98
|
-
}
|
|
99
|
-
return {
|
|
100
|
-
kind: input_.kind,
|
|
101
|
-
wingspan: input_.wingspan,
|
|
102
|
-
}!;
|
|
103
|
-
}
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
**Expectation for `jsonSparrowToTransportTransform`:**
|
|
107
|
-
Similarly, the serializer for a `Sparrow` instance should build upon the base Bird transformation and add the `kind` property accordingly.
|
|
108
|
-
|
|
109
|
-
```ts src/models/internal/serializers.ts function jsonSparrowToTransportTransform
|
|
110
|
-
export function jsonSparrowToTransportTransform(input_?: Sparrow | null): any {
|
|
111
|
-
if (!input_) {
|
|
112
|
-
return input_ as any;
|
|
113
|
-
}
|
|
114
|
-
return {
|
|
115
|
-
kind: input_.kind,
|
|
116
|
-
wingspan: input_.wingspan,
|
|
117
|
-
}!;
|
|
118
|
-
}
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
**Expectation for `jsonGooseToTransportTransform`:**
|
|
122
|
-
This function should transform a `Goose` instance by reusing the base Bird transformation and explicitly setting the `kind` property.
|
|
123
|
-
|
|
124
|
-
```ts src/models/internal/serializers.ts function jsonGooseToTransportTransform
|
|
125
|
-
export function jsonGooseToTransportTransform(input_?: Goose | null): any {
|
|
126
|
-
if (!input_) {
|
|
127
|
-
return input_ as any;
|
|
128
|
-
}
|
|
129
|
-
return {
|
|
130
|
-
kind: input_.kind,
|
|
131
|
-
wingspan: input_.wingspan,
|
|
132
|
-
}!;
|
|
133
|
-
}
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
**Expectation for `jsonEagleToTransportTransform`:**
|
|
137
|
-
The serializer for an `Eagle` instance is more complex due to additional properties. It must:
|
|
138
|
-
|
|
139
|
-
- Extend the base transformation (`jsonBirdToApplicationTransform`),
|
|
140
|
-
- Transform the `friends` property (an array of `Bird` instances) using `jsonArrayBirdToTransportTransform`,
|
|
141
|
-
- Transform the `hate` property (a primitive Record of `Bird` instances) using `jsonRecordBirdToTransportTransform`, and
|
|
142
|
-
- Transform the `partner` property (a single `Bird` instance) using `jsonBirdToApplicationTransform`.
|
|
143
|
-
|
|
144
|
-
```ts src/models/internal/serializers.ts function jsonEagleToTransportTransform
|
|
145
|
-
export function jsonEagleToTransportTransform(input_?: Eagle | null): any {
|
|
146
|
-
if (!input_) {
|
|
147
|
-
return input_ as any;
|
|
148
|
-
}
|
|
149
|
-
return {
|
|
150
|
-
kind: input_.kind,
|
|
151
|
-
friends: jsonArrayBirdToTransportTransform(input_.friends),
|
|
152
|
-
hate: jsonRecordBirdToTransportTransform(input_.hate),
|
|
153
|
-
partner: jsonBirdToTransportTransform(input_.partner),
|
|
154
|
-
wingspan: input_.wingspan,
|
|
155
|
-
}!;
|
|
156
|
-
}
|
|
157
|
-
```
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
# Property References in Model Serialization
|
|
2
|
-
|
|
3
|
-
This test verifies that property references in TypeSpec models are correctly serialized, particularly in scenarios involving nullable property references. This was created to address a specific issue where property references combined with nullable types were causing incorrect serialization.
|
|
4
|
-
|
|
5
|
-
## Background
|
|
6
|
-
|
|
7
|
-
When a model property references another model's property (e.g., `TodoItemPatch.title` referencing `TodoItem.title`), the emitter needs to:
|
|
8
|
-
|
|
9
|
-
1. Correctly unpack the referenced property
|
|
10
|
-
2. Handle cases where the reference is combined with a nullable type
|
|
11
|
-
3. Generate appropriate serialization code
|
|
12
|
-
|
|
13
|
-
### Key Concepts
|
|
14
|
-
|
|
15
|
-
- Property References: Using dot notation to reference properties from other models (e.g., `TodoItem.title`)
|
|
16
|
-
- Nullable References: Combining property references with null union type (e.g., `TodoItem.assignedTo | null`)
|
|
17
|
-
|
|
18
|
-
## Spec
|
|
19
|
-
|
|
20
|
-
```tsp
|
|
21
|
-
namespace Test;
|
|
22
|
-
model TodoItem {
|
|
23
|
-
id: safeint;
|
|
24
|
-
title: string;
|
|
25
|
-
assignedTo: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
model TodoItemPatch {
|
|
29
|
-
title?: TodoItem.title;
|
|
30
|
-
assignedTo?: TodoItem.assignedTo | null;
|
|
31
|
-
}
|
|
32
|
-
@patch op update(
|
|
33
|
-
@header contentType: "application/merge-patch+json",
|
|
34
|
-
@path id: TodoItem.id,
|
|
35
|
-
@body patch: TodoItemPatch,
|
|
36
|
-
): TodoItem;
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## Serializer
|
|
40
|
-
|
|
41
|
-
Validates that the serializer generates the correct serialization logic for:
|
|
42
|
-
|
|
43
|
-
- Direct property references (`title?: TodoItem.title`)
|
|
44
|
-
- Nullable property references (`assignedTo?: TodoItem.assignedTo | null`)
|
|
45
|
-
|
|
46
|
-
```ts src/models/internal/serializers.ts function jsonTodoItemPatchToTransportTransform
|
|
47
|
-
export function jsonTodoItemPatchToTransportTransform(input_?: TodoItemPatch | null): any {
|
|
48
|
-
if (!input_) {
|
|
49
|
-
return input_ as any;
|
|
50
|
-
}
|
|
51
|
-
return {
|
|
52
|
-
title: input_.title,
|
|
53
|
-
assignedTo: input_.assignedTo,
|
|
54
|
-
}!;
|
|
55
|
-
}
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
## Deserializer
|
|
59
|
-
|
|
60
|
-
Validates the deserialization logic maintains type consistency when converting from transport to application models.
|
|
61
|
-
|
|
62
|
-
```ts src/models/internal/serializers.ts function jsonTodoItemPatchToApplicationTransform
|
|
63
|
-
export function jsonTodoItemPatchToApplicationTransform(input_?: any): TodoItemPatch {
|
|
64
|
-
if (!input_) {
|
|
65
|
-
return input_ as any;
|
|
66
|
-
}
|
|
67
|
-
return {
|
|
68
|
-
title: input_.title,
|
|
69
|
-
assignedTo: input_.assignedTo,
|
|
70
|
-
}!;
|
|
71
|
-
}
|
|
72
|
-
```
|