@typespec/http-client-js 0.3.0-dev.1 → 0.3.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/CHANGELOG.md +0 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/eng/scripts/run-e2e-tests.js +1 -1
- package/package.json +15 -13
- package/test/e2e/http/type/model/visibility/main.test.ts +2 -2
- package/test/scenarios/additional-properties/extends.md +2 -2
- package/test/scenarios/additional-properties/spread.md +2 -2
- package/test/scenarios/auth/basic_auth.md +1 -0
- package/test/scenarios/auth/bearer.md +1 -0
- package/test/scenarios/auth/client_parameters.md +1 -0
- package/test/scenarios/auth/key_credential.md +1 -0
- package/test/scenarios/auth/sub_client_override.md +2 -0
- package/test/scenarios/client/dotted_namespace.md +1 -0
- package/test/scenarios/client/global_namespace.md +1 -0
- package/test/scenarios/client/multiple_top_level_clients.md +2 -0
- package/test/scenarios/client/nested_client.md +1 -0
- package/test/scenarios/encoding/bytes_json_property.md +1 -1
- package/test/scenarios/encoding/bytes_nullable.md +2 -2
- package/test/scenarios/encoding/model_with_bytes_property.md +1 -1
- package/test/scenarios/http-operations/basic-response.md +1 -1
- package/test/scenarios/http-operations/basic.md +2 -1
- package/test/scenarios/http-operations/optional-request-body.md +1 -1
- package/test/scenarios/http-operations/query-parameter.md +41 -0
- package/test/scenarios/http-operations/scalar-payload.md +1 -1
- package/test/scenarios/http-operations/with-parameters.md +1 -0
- package/test/scenarios/models/inheritance_2_discriminators.md +2 -2
- package/test/scenarios/models/inheritance_discriminator.md +4 -4
- package/test/scenarios/models/model_additional_properties.md +2 -2
- package/test/scenarios/models/model_extends.md +4 -4
- package/test/scenarios/models/model_spread.md +2 -2
- package/test/scenarios/models/property_references_property.md +4 -4
- package/test/scenarios/multipart/file_content_type.md +2 -2
- package/test/scenarios/operation-parameters/body_root_anonymous.md +1 -0
- package/test/scenarios/operation-parameters/constant_as_optional.md +1 -0
- package/test/scenarios/operation-parameters/default_value_as_optional.md +1 -0
- package/test/scenarios/operation-parameters/no_content_type.md +1 -0
- package/test/scenarios/operation-parameters/no_parameters.md +1 -0
- package/test/scenarios/operation-parameters/only_optional.md +1 -0
- package/test/scenarios/operation-parameters/only_required.md +1 -0
- package/test/scenarios/operation-parameters/reserved_names.md +1 -0
- package/test/scenarios/operation-parameters/spread_body.md +1 -0
- package/test/scenarios/operation-parameters/spread_with_nested.md +1 -0
- package/test/scenarios/operation-parameters/union_body.md +2 -1
- package/test/scenarios/operation-parameters/with_body_property.md +1 -0
- package/test/scenarios/operation-parameters/with_body_root.md +1 -0
- package/test/scenarios/serializers/arrays.md +6 -6
- package/test/scenarios/serializers/basic_model.md +4 -4
- package/test/scenarios/serializers/basic_model_wire_name.md +3 -3
- package/test/scenarios/serializers/discriminated_union.md +4 -4
- package/test/scenarios/serializers/discriminated_union_spread.md +5 -5
- package/test/scenarios/serializers/model_date_time.md +5 -5
- package/test/scenarios/serializers/polymorphic_single_level_inheritance.md +6 -6
- package/test/scenarios/serializers/property_references_property.md +2 -2
- package/test/scenarios/serializers/record.md +4 -4
- package/test/scenarios/serializers/spread.md +1 -1
- package/test/scenarios/serializers/string_union.md +1 -1
- package/test/scenarios.test.ts +11 -3
- package/vitest.config.e2e.ts +16 -0
- package/vitest.config.ts +26 -0
- package/vitest.config.js +0 -23
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typespec/http-client-js",
|
|
3
|
-
"version": "0.3.0-dev.
|
|
3
|
+
"version": "0.3.0-dev.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"homepage": "https://typespec.io",
|
|
6
6
|
"readme": "https://github.com/microsoft/typespec/blob/main/packages/http-client-js/README.md",
|
|
@@ -31,37 +31,37 @@
|
|
|
31
31
|
"@typespec/rest": "^0.67.1 || >=0.68.0-dev <0.68.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@typespec/emitter-framework": "^0.3.0 || >=0.4.0-dev <0.4.0",
|
|
35
|
-
"@typespec/http-client": "^0.3.0 || >=0.4.0-dev <0.4.0",
|
|
36
34
|
"@alloy-js/core": "^0.6.0",
|
|
37
35
|
"@alloy-js/typescript": "^0.6.0",
|
|
36
|
+
"@typespec/emitter-framework": "^0.3.0 || >=0.4.0-dev <0.4.0",
|
|
37
|
+
"@typespec/http-client": "^0.3.0 || >=0.4.0-dev <0.4.0",
|
|
38
38
|
"prettier": "~3.5.3"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@typespec/http": "^0.67.1 || >=0.68.0-dev <0.68.0",
|
|
42
41
|
"@alloy-js/babel-preset": "^0.2.0",
|
|
43
42
|
"@babel/cli": "^7.24.8",
|
|
44
|
-
"@babel/core": "^7.26.
|
|
43
|
+
"@babel/core": "^7.26.10",
|
|
45
44
|
"@rollup/plugin-babel": "^6.0.4",
|
|
46
45
|
"@types/yargs": "~17.0.33",
|
|
46
|
+
"@typespec/http": "^0.67.1 || >=0.68.0-dev <0.68.0",
|
|
47
47
|
"@typespec/http-specs": "^0.1.0-alpha.15 || >=0.1.0-alpha.16-dev <0.1.0-alpha.16",
|
|
48
48
|
"@typespec/spector": "^0.1.0-alpha.9 || >=0.1.0-alpha.10-dev <0.1.0-alpha.10",
|
|
49
49
|
"@typespec/ts-http-runtime": "0.1.0",
|
|
50
50
|
"@typespec/versioning": "^0.67.1 || >=0.68.0-dev <0.68.0",
|
|
51
|
-
"@vitest/ui": "^3.0.
|
|
52
|
-
"
|
|
51
|
+
"@vitest/ui": "^3.0.9",
|
|
52
|
+
"change-case": "~5.4.4",
|
|
53
53
|
"concurrently": "^9.1.2",
|
|
54
54
|
"execa": "^9.5.2",
|
|
55
55
|
"fs-extra": "^11.2.0",
|
|
56
56
|
"globby": "~14.1.0",
|
|
57
|
-
"inquirer": "^12.
|
|
57
|
+
"inquirer": "^12.5.0",
|
|
58
58
|
"ora": "^8.1.1",
|
|
59
59
|
"p-limit": "^6.2.0",
|
|
60
|
+
"picocolors": "~1.1.1",
|
|
60
61
|
"typescript": "~5.8.2",
|
|
61
62
|
"uri-template": "^2.0.0",
|
|
62
|
-
"vitest": "^3.0.
|
|
63
|
+
"vitest": "^3.0.9",
|
|
63
64
|
"yargs": "~17.7.2",
|
|
64
|
-
"change-case": "~5.4.4",
|
|
65
65
|
"@typespec/tspd": "^0.46.0"
|
|
66
66
|
},
|
|
67
67
|
"scripts": {
|
|
@@ -73,13 +73,15 @@
|
|
|
73
73
|
"watch-src": "babel src -d dist/src --extensions .ts,.tsx --watch",
|
|
74
74
|
"watch-tsc": "tsc -p . --watch",
|
|
75
75
|
"watch": "concurrently --kill-others \"npm run watch-tsc\" \"npm run watch-src\"",
|
|
76
|
-
"test
|
|
77
|
-
"test": "
|
|
76
|
+
"test": "vitest run",
|
|
77
|
+
"test:ui": "vitest --ui",
|
|
78
|
+
"test:watch": "vitest -w",
|
|
79
|
+
"test:ci": "vitest run --coverage --reporter=junit --reporter=default",
|
|
80
|
+
"test:e2e": "npm run emit:e2e && node eng/scripts/run-e2e-tests.js",
|
|
78
81
|
"format": "prettier . --write",
|
|
79
82
|
"build:test": "tsc -p tsconfig.test.json",
|
|
80
83
|
"start:server": "npx tsp-spector server start node_modules/@typespec/http-specs/specs --coverageFile ./temp/tsp-spector-coverage-javascript-standard.json --debug",
|
|
81
84
|
"stop:server": "npx tsp-spector server stop",
|
|
82
|
-
"test:e2e": "npm run emit:e2e && node eng/scripts/run-e2e-tests.js",
|
|
83
85
|
"run:e2e": "node eng/scripts/run-e2e-tests.js",
|
|
84
86
|
"regen-docs": "tspd doc . --enable-experimental --output-dir ../../website/src/content/docs/docs/emitters/clients/http-client-js/reference --skip-js",
|
|
85
87
|
"emit:e2e": "node eng/scripts/emit-e2e.js"
|
|
@@ -4,7 +4,7 @@ import { VisibilityClient } from "../../../../generated/type/model/visibility/sr
|
|
|
4
4
|
describe("Type.Model.Visibility", () => {
|
|
5
5
|
const client = new VisibilityClient({ allowInsecureConnection: true });
|
|
6
6
|
|
|
7
|
-
it("should generate and receive an output model with readonly properties (getModel)", async () => {
|
|
7
|
+
it.skip("should generate and receive an output model with readonly properties (getModel)", async () => {
|
|
8
8
|
const input = {
|
|
9
9
|
queryProp: 123,
|
|
10
10
|
};
|
|
@@ -12,7 +12,7 @@ describe("Type.Model.Visibility", () => {
|
|
|
12
12
|
expect(response.readProp).toBe("abc");
|
|
13
13
|
});
|
|
14
14
|
|
|
15
|
-
it("should send a model with write/create properties (headModel)", async () => {
|
|
15
|
+
it.skip("should send a model with write/create properties (headModel)", async () => {
|
|
16
16
|
const input = {
|
|
17
17
|
queryProp: 123,
|
|
18
18
|
};
|
|
@@ -32,7 +32,7 @@ export interface Widget {
|
|
|
32
32
|
|
|
33
33
|
The deserializer flattens the additional property envelope into the root of the payload
|
|
34
34
|
|
|
35
|
-
```ts src/models/serializers.ts function jsonWidgetToTransportTransform
|
|
35
|
+
```ts src/models/internal/serializers.ts function jsonWidgetToTransportTransform
|
|
36
36
|
export function jsonWidgetToTransportTransform(input_?: Widget | null): any {
|
|
37
37
|
if (!input_) {
|
|
38
38
|
return input_ as any;
|
|
@@ -50,7 +50,7 @@ export function jsonWidgetToTransportTransform(input_?: Widget | null): any {
|
|
|
50
50
|
|
|
51
51
|
Deserializer puts the known properties in the root of the object and creates an additional Properties envelope.
|
|
52
52
|
|
|
53
|
-
```ts src/models/serializers.ts function jsonWidgetToApplicationTransform
|
|
53
|
+
```ts src/models/internal/serializers.ts function jsonWidgetToApplicationTransform
|
|
54
54
|
export function jsonWidgetToApplicationTransform(input_?: any): Widget {
|
|
55
55
|
if (!input_) {
|
|
56
56
|
return input_ as any;
|
|
@@ -33,7 +33,7 @@ export interface Widget {
|
|
|
33
33
|
|
|
34
34
|
The deserializer flattens the additional property envelope into the root of the payload
|
|
35
35
|
|
|
36
|
-
```ts src/models/serializers.ts function jsonWidgetToTransportTransform
|
|
36
|
+
```ts src/models/internal/serializers.ts function jsonWidgetToTransportTransform
|
|
37
37
|
export function jsonWidgetToTransportTransform(input_?: Widget | null): any {
|
|
38
38
|
if (!input_) {
|
|
39
39
|
return input_ as any;
|
|
@@ -51,7 +51,7 @@ export function jsonWidgetToTransportTransform(input_?: Widget | null): any {
|
|
|
51
51
|
|
|
52
52
|
Deserializer puts the known properties in the root of the object and creates an additional Properties envelope.
|
|
53
53
|
|
|
54
|
-
```ts src/models/serializers.ts function jsonWidgetToApplicationTransform
|
|
54
|
+
```ts src/models/internal/serializers.ts function jsonWidgetToApplicationTransform
|
|
55
55
|
export function jsonWidgetToApplicationTransform(input_?: any): Widget {
|
|
56
56
|
if (!input_) {
|
|
57
57
|
return input_ as any;
|
|
@@ -25,6 +25,7 @@ The client signature should include a positional parameter for credential of typ
|
|
|
25
25
|
```ts src/testClient.ts class TestClient
|
|
26
26
|
export class TestClient {
|
|
27
27
|
#context: TestClientContext;
|
|
28
|
+
|
|
28
29
|
constructor(endpoint: string, credential: KeyCredential, options?: TestClientOptions) {
|
|
29
30
|
this.#context = createTestClientContext(endpoint, credential, options);
|
|
30
31
|
}
|
|
@@ -25,6 +25,7 @@ The client signature should include a positional parameter for credential of typ
|
|
|
25
25
|
```ts src/testClient.ts class TestClient
|
|
26
26
|
export class TestClient {
|
|
27
27
|
#context: TestClientContext;
|
|
28
|
+
|
|
28
29
|
constructor(endpoint: string, credential: KeyCredential, options?: TestClientOptions) {
|
|
29
30
|
this.#context = createTestClientContext(endpoint, credential, options);
|
|
30
31
|
}
|
|
@@ -26,6 +26,7 @@ TODO: Revisit if we need additional types since it will be difficult at runtime
|
|
|
26
26
|
```ts src/testClient.ts class TestClient
|
|
27
27
|
export class TestClient {
|
|
28
28
|
#context: TestClientContext;
|
|
29
|
+
|
|
29
30
|
constructor(endpoint: string, credential: KeyCredential, options?: TestClientOptions) {
|
|
30
31
|
this.#context = createTestClientContext(endpoint, credential, options);
|
|
31
32
|
}
|
|
@@ -25,6 +25,7 @@ The client signature should include a positional parameter for credential of typ
|
|
|
25
25
|
```ts src/testClient.ts class TestClient
|
|
26
26
|
export class TestClient {
|
|
27
27
|
#context: TestClientContext;
|
|
28
|
+
|
|
28
29
|
constructor(endpoint: string, credential: KeyCredential, options?: TestClientOptions) {
|
|
29
30
|
this.#context = createTestClientContext(endpoint, credential, options);
|
|
30
31
|
}
|
|
@@ -34,6 +34,7 @@ The subclient is not a child of the TestClient because they have different param
|
|
|
34
34
|
```ts src/testClient.ts class TestClient
|
|
35
35
|
export class TestClient {
|
|
36
36
|
#context: TestClientContext;
|
|
37
|
+
|
|
37
38
|
constructor(endpoint: string, credential: KeyCredential, options?: TestClientOptions) {
|
|
38
39
|
this.#context = createTestClientContext(endpoint, credential, options);
|
|
39
40
|
}
|
|
@@ -48,6 +49,7 @@ The sub client shouldn't take a credential
|
|
|
48
49
|
```ts src/testClient.ts class SubClient
|
|
49
50
|
export class SubClient {
|
|
50
51
|
#context: SubClientContext;
|
|
52
|
+
|
|
51
53
|
constructor(endpoint: string, options?: SubClientOptions) {
|
|
52
54
|
this.#context = createSubClientContext(endpoint, options);
|
|
53
55
|
}
|
|
@@ -17,6 +17,7 @@ The client should match the last namespace.
|
|
|
17
17
|
```ts src/bazClient.ts class BazClient
|
|
18
18
|
export class BazClient {
|
|
19
19
|
#context: BazClientContext;
|
|
20
|
+
|
|
20
21
|
constructor(endpoint: string, options?: BazClientOptions) {
|
|
21
22
|
this.#context = createBazClientContext(endpoint, options);
|
|
22
23
|
}
|
|
@@ -39,6 +39,7 @@ It should generate a client for the Global Namespace with a single operation `fo
|
|
|
39
39
|
```ts src/client.ts class Client
|
|
40
40
|
export class Client {
|
|
41
41
|
#context: ClientContext;
|
|
42
|
+
|
|
42
43
|
constructor(endpoint: string, options?: ClientOptions) {
|
|
43
44
|
this.#context = createClientContext(endpoint, options);
|
|
44
45
|
}
|
|
@@ -37,6 +37,7 @@ import {
|
|
|
37
37
|
|
|
38
38
|
export class FooClient {
|
|
39
39
|
#context: FooClientContext;
|
|
40
|
+
|
|
40
41
|
constructor(endpoint: string, options?: FooClientOptions) {
|
|
41
42
|
this.#context = createFooClientContext(endpoint, options);
|
|
42
43
|
}
|
|
@@ -59,6 +60,7 @@ import {
|
|
|
59
60
|
|
|
60
61
|
export class BarClient {
|
|
61
62
|
#context: BarClientContext;
|
|
63
|
+
|
|
62
64
|
constructor(endpoint: string, options?: BarClientOptions) {
|
|
63
65
|
this.#context = createBarClientContext(endpoint, options);
|
|
64
66
|
}
|
|
@@ -43,7 +43,7 @@ export async function foo(
|
|
|
43
43
|
|
|
44
44
|
## Deserializer
|
|
45
45
|
|
|
46
|
-
```ts src/models/serializers.ts function jsonBytesBodyToApplicationTransform
|
|
46
|
+
```ts src/models/internal/serializers.ts function jsonBytesBodyToApplicationTransform
|
|
47
47
|
export function jsonBytesBodyToApplicationTransform(input_?: any): BytesBody {
|
|
48
48
|
if (!input_) {
|
|
49
49
|
return input_ as any;
|
|
@@ -46,7 +46,7 @@ export async function get(
|
|
|
46
46
|
|
|
47
47
|
Should decode as uint8array the nullableProperty
|
|
48
48
|
|
|
49
|
-
```ts src/models/serializers.ts function jsonModelWithBytesToApplicationTransform
|
|
49
|
+
```ts src/models/internal/serializers.ts function jsonModelWithBytesToApplicationTransform
|
|
50
50
|
export function jsonModelWithBytesToApplicationTransform(input_?: any): ModelWithBytes {
|
|
51
51
|
if (!input_) {
|
|
52
52
|
return input_ as any;
|
|
@@ -126,7 +126,7 @@ export async function post(
|
|
|
126
126
|
|
|
127
127
|
Should encode as base64 the nullableProperty
|
|
128
128
|
|
|
129
|
-
```ts src/models/serializers.ts function jsonModelWithBytesToTransportTransform
|
|
129
|
+
```ts src/models/internal/serializers.ts function jsonModelWithBytesToTransportTransform
|
|
130
130
|
export function jsonModelWithBytesToTransportTransform(input_?: ModelWithBytes | null): any {
|
|
131
131
|
if (!input_) {
|
|
132
132
|
return input_ as any;
|
|
@@ -33,7 +33,7 @@ export async function get(client: TestClientContext, options?: GetOptions): Prom
|
|
|
33
33
|
}
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
```ts src/models/serializers.ts function jsonBytesPropertyToApplicationTransform
|
|
36
|
+
```ts src/models/internal/serializers.ts function jsonBytesPropertyToApplicationTransform
|
|
37
37
|
export function jsonBytesPropertyToApplicationTransform(input_?: any): BytesProperty {
|
|
38
38
|
if (!input_) {
|
|
39
39
|
return input_ as any;
|
|
@@ -68,7 +68,7 @@ interface Widgets {
|
|
|
68
68
|
|
|
69
69
|
This function converts the received JSON response into a `Widget` instance.
|
|
70
70
|
|
|
71
|
-
```ts src/models/serializers.ts function jsonWidgetToApplicationTransform
|
|
71
|
+
```ts src/models/internal/serializers.ts function jsonWidgetToApplicationTransform
|
|
72
72
|
export function jsonWidgetToApplicationTransform(input_?: any): Widget {
|
|
73
73
|
if (!input_) {
|
|
74
74
|
return input_ as any;
|
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
|
|
33
33
|
export class TestClient {
|
|
34
34
|
#context: TestClientContext;
|
|
35
|
+
|
|
35
36
|
constructor(endpoint: string, options?: TestClientOptions) {
|
|
36
37
|
this.#context = createTestClientContext(endpoint, options);
|
|
37
38
|
}
|
|
@@ -57,7 +58,7 @@ export interface Widget {
|
|
|
57
58
|
|
|
58
59
|
A serializer function, `jsonWidgetToTransportTransform`, is generated to transform the `Widget` model into its transport format. It converts TypeScript-friendly property names (`totalWeight`) back to their wire format (`total_weight`).
|
|
59
60
|
|
|
60
|
-
```ts src/models/serializers.ts function jsonWidgetToTransportTransform
|
|
61
|
+
```ts src/models/internal/serializers.ts function jsonWidgetToTransportTransform
|
|
61
62
|
export function jsonWidgetToTransportTransform(input_?: Widget | null): any {
|
|
62
63
|
if (!input_) {
|
|
63
64
|
return input_ as any;
|
|
@@ -38,7 +38,7 @@ export async function set(client: TestClientContext, options?: SetOptions): Prom
|
|
|
38
38
|
|
|
39
39
|
## Transform
|
|
40
40
|
|
|
41
|
-
```ts src/models/serializers.ts function jsonBodyModelToTransportTransform
|
|
41
|
+
```ts src/models/internal/serializers.ts function jsonBodyModelToTransportTransform
|
|
42
42
|
export function jsonBodyModelToTransportTransform(input_?: BodyModel | null): any {
|
|
43
43
|
if (!input_) {
|
|
44
44
|
return input_ as any;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Should handle a header parameter within @bodyRoot
|
|
2
|
+
|
|
3
|
+
```tsp
|
|
4
|
+
namespace Test;
|
|
5
|
+
|
|
6
|
+
model VisibilityModel {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
age?: string;
|
|
10
|
+
@header foo?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@head op headModel(@bodyRoot input: VisibilityModel): OkResponse;
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Operation
|
|
17
|
+
|
|
18
|
+
```ts src/api/testClientOperations.ts function headModel
|
|
19
|
+
export async function headModel(
|
|
20
|
+
client: TestClientContext,
|
|
21
|
+
input: VisibilityModel,
|
|
22
|
+
options?: HeadModelOptions,
|
|
23
|
+
): Promise<void> {
|
|
24
|
+
const path = parse("/").expand({});
|
|
25
|
+
const httpRequestOptions = {
|
|
26
|
+
headers: {
|
|
27
|
+
...(options?.foo && { foo: options?.foo }),
|
|
28
|
+
},
|
|
29
|
+
body: jsonVisibilityModelToTransportTransform(input),
|
|
30
|
+
};
|
|
31
|
+
const response = await client.pathUnchecked(path).head(httpRequestOptions);
|
|
32
|
+
|
|
33
|
+
if (typeof options?.operationOptions?.onResponse === "function") {
|
|
34
|
+
options?.operationOptions?.onResponse(response);
|
|
35
|
+
}
|
|
36
|
+
if (+response.status === 200 && !response.body) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
throw createRestError(response);
|
|
40
|
+
}
|
|
41
|
+
```
|
|
@@ -50,7 +50,7 @@ export async function create(
|
|
|
50
50
|
|
|
51
51
|
The correct serializer function is created, since this is a number payload, no additional serialization is needed.
|
|
52
52
|
|
|
53
|
-
```ts src/models/serializers.ts function createPayloadToTransport
|
|
53
|
+
```ts src/models/internal/serializers.ts function createPayloadToTransport
|
|
54
54
|
export function createPayloadToTransport(payload: number) {
|
|
55
55
|
return payload!;
|
|
56
56
|
}
|
|
@@ -68,6 +68,7 @@ It should generate the client class with the read operation that calls the opera
|
|
|
68
68
|
```ts src/demoServiceClient.ts class WidgetsClient
|
|
69
69
|
export class WidgetsClient {
|
|
70
70
|
#context: WidgetsClientContext;
|
|
71
|
+
|
|
71
72
|
constructor(endpoint: string, options?: WidgetsClientOptions) {
|
|
72
73
|
this.#context = createWidgetsClientContext(endpoint, options);
|
|
73
74
|
}
|
|
@@ -57,8 +57,8 @@ export async function getModel(
|
|
|
57
57
|
}
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
```ts src/models/serializers.ts
|
|
61
|
-
import { Fish, Shark, SawShark, GoblinShark, Salmon } from "
|
|
60
|
+
```ts src/models/internal/serializers.ts
|
|
61
|
+
import { Fish, Shark, SawShark, GoblinShark, Salmon } from "../models.js";
|
|
62
62
|
|
|
63
63
|
export function decodeBase64(value: string): Uint8Array | undefined {
|
|
64
64
|
if (!value) {
|
|
@@ -35,7 +35,7 @@ export interface TRex extends Dinosaur {
|
|
|
35
35
|
|
|
36
36
|
## Serializer
|
|
37
37
|
|
|
38
|
-
```ts src/models/serializers.ts function jsonDinosaurToTransportTransform
|
|
38
|
+
```ts src/models/internal/serializers.ts function jsonDinosaurToTransportTransform
|
|
39
39
|
export function jsonDinosaurToTransportTransform(input_?: Dinosaur | null): any {
|
|
40
40
|
if (!input_) {
|
|
41
41
|
return input_ as any;
|
|
@@ -48,7 +48,7 @@ export function jsonDinosaurToTransportTransform(input_?: Dinosaur | null): any
|
|
|
48
48
|
}
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
-
```ts src/models/serializers.ts function jsonTRexToTransportTransform
|
|
51
|
+
```ts src/models/internal/serializers.ts function jsonTRexToTransportTransform
|
|
52
52
|
export function jsonTRexToTransportTransform(input_?: TRex | null): any {
|
|
53
53
|
if (!input_) {
|
|
54
54
|
return input_ as any;
|
|
@@ -62,7 +62,7 @@ export function jsonTRexToTransportTransform(input_?: TRex | null): any {
|
|
|
62
62
|
|
|
63
63
|
## Deserializer
|
|
64
64
|
|
|
65
|
-
```ts src/models/serializers.ts function jsonDinosaurToApplicationTransform
|
|
65
|
+
```ts src/models/internal/serializers.ts function jsonDinosaurToApplicationTransform
|
|
66
66
|
export function jsonDinosaurToApplicationTransform(input_?: any): Dinosaur {
|
|
67
67
|
if (!input_) {
|
|
68
68
|
return input_ as any;
|
|
@@ -75,7 +75,7 @@ export function jsonDinosaurToApplicationTransform(input_?: any): Dinosaur {
|
|
|
75
75
|
}
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
-
```ts src/models/serializers.ts function jsonTRexToApplicationTransform
|
|
78
|
+
```ts src/models/internal/serializers.ts function jsonTRexToApplicationTransform
|
|
79
79
|
export function jsonTRexToApplicationTransform(input_?: any): TRex {
|
|
80
80
|
if (!input_) {
|
|
81
81
|
return input_ as any;
|
|
@@ -42,7 +42,7 @@ export interface Dog {
|
|
|
42
42
|
|
|
43
43
|
## Serializer
|
|
44
44
|
|
|
45
|
-
```ts src/models/serializers.ts function jsonDogToTransportTransform
|
|
45
|
+
```ts src/models/internal/serializers.ts function jsonDogToTransportTransform
|
|
46
46
|
export function jsonDogToTransportTransform(input_?: Dog | null): any {
|
|
47
47
|
if (!input_) {
|
|
48
48
|
return input_ as any;
|
|
@@ -58,7 +58,7 @@ export function jsonDogToTransportTransform(input_?: Dog | null): any {
|
|
|
58
58
|
|
|
59
59
|
## Deserializer
|
|
60
60
|
|
|
61
|
-
```ts src/models/serializers.ts function jsonDogToApplicationTransform
|
|
61
|
+
```ts src/models/internal/serializers.ts function jsonDogToApplicationTransform
|
|
62
62
|
export function jsonDogToApplicationTransform(input_?: any): Dog {
|
|
63
63
|
if (!input_) {
|
|
64
64
|
return input_ as any;
|
|
@@ -40,7 +40,7 @@ Should generate a serializer for Pet. Also a serializer for Dog that calls the P
|
|
|
40
40
|
|
|
41
41
|
### Pet Serializer
|
|
42
42
|
|
|
43
|
-
```ts src/models/serializers.ts function jsonPetToTransportTransform
|
|
43
|
+
```ts src/models/internal/serializers.ts function jsonPetToTransportTransform
|
|
44
44
|
export function jsonPetToTransportTransform(input_?: Pet | null): any {
|
|
45
45
|
if (!input_) {
|
|
46
46
|
return input_ as any;
|
|
@@ -54,7 +54,7 @@ export function jsonPetToTransportTransform(input_?: Pet | null): any {
|
|
|
54
54
|
|
|
55
55
|
### Pet deserializer
|
|
56
56
|
|
|
57
|
-
```ts src/models/serializers.ts function jsonPetToApplicationTransform
|
|
57
|
+
```ts src/models/internal/serializers.ts function jsonPetToApplicationTransform
|
|
58
58
|
export function jsonPetToApplicationTransform(input_?: any): Pet {
|
|
59
59
|
if (!input_) {
|
|
60
60
|
return input_ as any;
|
|
@@ -68,7 +68,7 @@ export function jsonPetToApplicationTransform(input_?: any): Pet {
|
|
|
68
68
|
|
|
69
69
|
### Dog Serializer
|
|
70
70
|
|
|
71
|
-
```ts src/models/serializers.ts function jsonDogToTransportTransform
|
|
71
|
+
```ts src/models/internal/serializers.ts function jsonDogToTransportTransform
|
|
72
72
|
export function jsonDogToTransportTransform(input_?: Dog | null): any {
|
|
73
73
|
if (!input_) {
|
|
74
74
|
return input_ as any;
|
|
@@ -83,7 +83,7 @@ export function jsonDogToTransportTransform(input_?: Dog | null): any {
|
|
|
83
83
|
|
|
84
84
|
### Dog deserializer
|
|
85
85
|
|
|
86
|
-
```ts src/models/serializers.ts function jsonDogToApplicationTransform
|
|
86
|
+
```ts src/models/internal/serializers.ts function jsonDogToApplicationTransform
|
|
87
87
|
export function jsonDogToApplicationTransform(input_?: any): Dog {
|
|
88
88
|
if (!input_) {
|
|
89
89
|
return input_ as any;
|
|
@@ -34,7 +34,7 @@ export interface Dog {
|
|
|
34
34
|
|
|
35
35
|
### Dog Serializer
|
|
36
36
|
|
|
37
|
-
```ts src/models/serializers.ts function jsonDogToTransportTransform
|
|
37
|
+
```ts src/models/internal/serializers.ts function jsonDogToTransportTransform
|
|
38
38
|
export function jsonDogToTransportTransform(input_?: Dog | null): any {
|
|
39
39
|
if (!input_) {
|
|
40
40
|
return input_ as any;
|
|
@@ -49,7 +49,7 @@ export function jsonDogToTransportTransform(input_?: Dog | null): any {
|
|
|
49
49
|
|
|
50
50
|
### Dog deserializer
|
|
51
51
|
|
|
52
|
-
```ts src/models/serializers.ts function jsonDogToApplicationTransform
|
|
52
|
+
```ts src/models/internal/serializers.ts function jsonDogToApplicationTransform
|
|
53
53
|
export function jsonDogToApplicationTransform(input_?: any): Dog {
|
|
54
54
|
if (!input_) {
|
|
55
55
|
return input_ as any;
|
|
@@ -33,7 +33,7 @@ export interface Bar {
|
|
|
33
33
|
|
|
34
34
|
Should emit a serializer for this model
|
|
35
35
|
|
|
36
|
-
```ts src/models/serializers.ts function jsonBarToTransportTransform
|
|
36
|
+
```ts src/models/internal/serializers.ts function jsonBarToTransportTransform
|
|
37
37
|
export function jsonBarToTransportTransform(input_?: Bar | null): any {
|
|
38
38
|
if (!input_) {
|
|
39
39
|
return input_ as any;
|
|
@@ -47,8 +47,8 @@ export function jsonBarToTransportTransform(input_?: Bar | null): any {
|
|
|
47
47
|
|
|
48
48
|
Should emit an operation serializer
|
|
49
49
|
|
|
50
|
-
```ts src/models/serializers.ts
|
|
51
|
-
import { Bar } from "
|
|
50
|
+
```ts src/models/internal/serializers.ts
|
|
51
|
+
import { Bar } from "../models.js";
|
|
52
52
|
|
|
53
53
|
export function decodeBase64(value: string): Uint8Array | undefined {
|
|
54
54
|
if (!value) {
|
|
@@ -137,7 +137,7 @@ export function jsonBarToApplicationTransform(input_?: any): Bar {
|
|
|
137
137
|
|
|
138
138
|
Should emit a serializer for this model
|
|
139
139
|
|
|
140
|
-
```ts src/models/serializers.ts function jsonBarToApplicationTransform
|
|
140
|
+
```ts src/models/internal/serializers.ts function jsonBarToApplicationTransform
|
|
141
141
|
export function jsonBarToApplicationTransform(input_?: any): Bar {
|
|
142
142
|
if (!input_) {
|
|
143
143
|
return input_ as any;
|
|
@@ -48,7 +48,7 @@ export async function imageJpegContentType(
|
|
|
48
48
|
|
|
49
49
|
## Serializers
|
|
50
50
|
|
|
51
|
-
```ts src/models/serializers.ts function jsonFileWithHttpPartSpecificContentTypeRequestToApplicationTransform
|
|
51
|
+
```ts src/models/internal/serializers.ts function jsonFileWithHttpPartSpecificContentTypeRequestToApplicationTransform
|
|
52
52
|
export function jsonFileWithHttpPartSpecificContentTypeRequestToApplicationTransform(
|
|
53
53
|
input_?: any,
|
|
54
54
|
): FileWithHttpPartSpecificContentTypeRequest {
|
|
@@ -61,7 +61,7 @@ export function jsonFileWithHttpPartSpecificContentTypeRequestToApplicationTrans
|
|
|
61
61
|
}
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
-
```ts src/models/serializers.ts function jsonFileSpecificContentTypeToApplicationTransform
|
|
64
|
+
```ts src/models/internal/serializers.ts function jsonFileSpecificContentTypeToApplicationTransform
|
|
65
65
|
export function jsonFileSpecificContentTypeToApplicationTransform(
|
|
66
66
|
input_?: any,
|
|
67
67
|
): FileSpecificContentType {
|
|
@@ -64,6 +64,7 @@ export interface CreateOptions extends OperationOptions {
|
|
|
64
64
|
```ts src/testClient.ts class TestClient
|
|
65
65
|
export class TestClient {
|
|
66
66
|
#context: TestClientContext;
|
|
67
|
+
|
|
67
68
|
constructor(endpoint: string, options?: TestClientOptions) {
|
|
68
69
|
this.#context = createTestClientContext(endpoint, options);
|
|
69
70
|
}
|
|
@@ -44,6 +44,7 @@ export interface GetOptions extends OperationOptions {
|
|
|
44
44
|
```ts src/testClient.ts class TestClient
|
|
45
45
|
export class TestClient {
|
|
46
46
|
#context: TestClientContext;
|
|
47
|
+
|
|
47
48
|
constructor(endpoint: string, options?: TestClientOptions) {
|
|
48
49
|
this.#context = createTestClientContext(endpoint, options);
|
|
49
50
|
}
|
|
@@ -44,6 +44,7 @@ export interface GetOptions extends OperationOptions {
|
|
|
44
44
|
```ts src/testClient.ts class TestClient
|
|
45
45
|
export class TestClient {
|
|
46
46
|
#context: TestClientContext;
|
|
47
|
+
|
|
47
48
|
constructor(endpoint: string, options?: TestClientOptions) {
|
|
48
49
|
this.#context = createTestClientContext(endpoint, options);
|
|
49
50
|
}
|
|
@@ -52,6 +52,7 @@ export interface GetOptions extends OperationOptions {}
|
|
|
52
52
|
```ts src/testClient.ts class TestClient
|
|
53
53
|
export class TestClient {
|
|
54
54
|
#context: TestClientContext;
|
|
55
|
+
|
|
55
56
|
constructor(endpoint: string, options?: TestClientOptions) {
|
|
56
57
|
this.#context = createTestClientContext(endpoint, options);
|
|
57
58
|
}
|
|
@@ -40,6 +40,7 @@ export interface GetOptions extends OperationOptions {}
|
|
|
40
40
|
```ts src/testClient.ts class TestClient
|
|
41
41
|
export class TestClient {
|
|
42
42
|
#context: TestClientContext;
|
|
43
|
+
|
|
43
44
|
constructor(endpoint: string, options?: TestClientOptions) {
|
|
44
45
|
this.#context = createTestClientContext(endpoint, options);
|
|
45
46
|
}
|
|
@@ -52,6 +52,7 @@ export interface GetWithParamsOptions extends OperationOptions {
|
|
|
52
52
|
```ts src/testClient.ts class TestClient
|
|
53
53
|
export class TestClient {
|
|
54
54
|
#context: TestClientContext;
|
|
55
|
+
|
|
55
56
|
constructor(endpoint: string, options?: TestClientOptions) {
|
|
56
57
|
this.#context = createTestClientContext(endpoint, options);
|
|
57
58
|
}
|
|
@@ -48,6 +48,7 @@ export interface GetWithParamsOptions extends OperationOptions {}
|
|
|
48
48
|
```ts src/testClient.ts class TestClient
|
|
49
49
|
export class TestClient {
|
|
50
50
|
#context: TestClientContext;
|
|
51
|
+
|
|
51
52
|
constructor(endpoint: string, options?: TestClientOptions) {
|
|
52
53
|
this.#context = createTestClientContext(endpoint, options);
|
|
53
54
|
}
|
|
@@ -50,6 +50,7 @@ export interface GetOptions extends OperationOptions {
|
|
|
50
50
|
```ts src/testClient.ts class TestClient
|
|
51
51
|
export class TestClient {
|
|
52
52
|
#context: TestClientContext;
|
|
53
|
+
|
|
53
54
|
constructor(endpoint: string, options?: TestClientOptions) {
|
|
54
55
|
this.#context = createTestClientContext(endpoint, options);
|
|
55
56
|
}
|
|
@@ -60,6 +60,7 @@ export interface CreateOptions extends OperationOptions {
|
|
|
60
60
|
```ts src/testClient.ts class TestClient
|
|
61
61
|
export class TestClient {
|
|
62
62
|
#context: TestClientContext;
|
|
63
|
+
|
|
63
64
|
constructor(endpoint: string, options?: TestClientOptions) {
|
|
64
65
|
this.#context = createTestClientContext(endpoint, options);
|
|
65
66
|
}
|
|
@@ -72,6 +72,7 @@ export interface CreateOptions extends OperationOptions {
|
|
|
72
72
|
```ts src/testClient.ts class TestClient
|
|
73
73
|
export class TestClient {
|
|
74
74
|
#context: TestClientContext;
|
|
75
|
+
|
|
75
76
|
constructor(endpoint: string, options?: TestClientOptions) {
|
|
76
77
|
this.#context = createTestClientContext(endpoint, options);
|
|
77
78
|
}
|