@typespec/http-client-js 0.3.0-dev.0 → 0.3.0-dev.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.
Files changed (69) hide show
  1. package/CHANGELOG.md +0 -3
  2. package/dist/src/components/client.d.ts.map +1 -1
  3. package/dist/src/components/client.js +6 -6
  4. package/dist/src/components/client.js.map +1 -1
  5. package/dist/src/emitter.d.ts.map +1 -1
  6. package/dist/src/emitter.js +6 -1
  7. package/dist/src/emitter.js.map +1 -1
  8. package/dist/tsconfig.tsbuildinfo +1 -1
  9. package/eng/scripts/run-e2e-tests.js +1 -1
  10. package/package.json +16 -14
  11. package/src/components/client.tsx +7 -8
  12. package/src/emitter.tsx +3 -1
  13. package/test/e2e/http/encode/bytes/main.test.ts +1 -1
  14. package/test/e2e/http/type/model/visibility/main.test.ts +2 -2
  15. package/test/scenarios/additional-properties/extends.md +2 -2
  16. package/test/scenarios/additional-properties/spread.md +2 -2
  17. package/test/scenarios/auth/basic_auth.md +1 -0
  18. package/test/scenarios/auth/bearer.md +1 -0
  19. package/test/scenarios/auth/client_parameters.md +1 -0
  20. package/test/scenarios/auth/key_credential.md +1 -0
  21. package/test/scenarios/auth/sub_client_override.md +2 -0
  22. package/test/scenarios/client/dotted_namespace.md +1 -0
  23. package/test/scenarios/client/global_namespace.md +1 -0
  24. package/test/scenarios/client/multiple_top_level_clients.md +2 -0
  25. package/test/scenarios/client/nested_client.md +1 -0
  26. package/test/scenarios/encoding/bytes_json_property.md +1 -1
  27. package/test/scenarios/encoding/bytes_nullable.md +2 -2
  28. package/test/scenarios/encoding/model_with_bytes_property.md +1 -1
  29. package/test/scenarios/http-operations/basic-response.md +1 -1
  30. package/test/scenarios/http-operations/basic.md +2 -1
  31. package/test/scenarios/http-operations/optional-request-body.md +1 -1
  32. package/test/scenarios/http-operations/query-parameter.md +41 -0
  33. package/test/scenarios/http-operations/scalar-payload.md +1 -1
  34. package/test/scenarios/http-operations/with-parameters.md +1 -0
  35. package/test/scenarios/models/inheritance_2_discriminators.md +2 -2
  36. package/test/scenarios/models/inheritance_discriminator.md +4 -4
  37. package/test/scenarios/models/model_additional_properties.md +2 -2
  38. package/test/scenarios/models/model_extends.md +4 -4
  39. package/test/scenarios/models/model_spread.md +2 -2
  40. package/test/scenarios/models/property_references_property.md +4 -4
  41. package/test/scenarios/multipart/file_content_type.md +2 -2
  42. package/test/scenarios/operation-parameters/body_root_anonymous.md +1 -0
  43. package/test/scenarios/operation-parameters/constant_as_optional.md +1 -0
  44. package/test/scenarios/operation-parameters/default_value_as_optional.md +1 -0
  45. package/test/scenarios/operation-parameters/no_content_type.md +1 -0
  46. package/test/scenarios/operation-parameters/no_parameters.md +1 -0
  47. package/test/scenarios/operation-parameters/only_optional.md +1 -0
  48. package/test/scenarios/operation-parameters/only_required.md +1 -0
  49. package/test/scenarios/operation-parameters/reserved_names.md +1 -0
  50. package/test/scenarios/operation-parameters/spread_body.md +1 -0
  51. package/test/scenarios/operation-parameters/spread_with_nested.md +1 -0
  52. package/test/scenarios/operation-parameters/union_body.md +2 -1
  53. package/test/scenarios/operation-parameters/with_body_property.md +1 -0
  54. package/test/scenarios/operation-parameters/with_body_root.md +1 -0
  55. package/test/scenarios/serializers/arrays.md +6 -6
  56. package/test/scenarios/serializers/basic_model.md +4 -4
  57. package/test/scenarios/serializers/basic_model_wire_name.md +3 -3
  58. package/test/scenarios/serializers/discriminated_union.md +4 -4
  59. package/test/scenarios/serializers/discriminated_union_spread.md +5 -5
  60. package/test/scenarios/serializers/model_date_time.md +5 -5
  61. package/test/scenarios/serializers/polymorphic_single_level_inheritance.md +6 -6
  62. package/test/scenarios/serializers/property_references_property.md +2 -2
  63. package/test/scenarios/serializers/record.md +4 -4
  64. package/test/scenarios/serializers/spread.md +1 -1
  65. package/test/scenarios/serializers/string_union.md +1 -1
  66. package/test/scenarios.test.ts +11 -3
  67. package/vitest.config.e2e.ts +16 -0
  68. package/vitest.config.ts +26 -0
  69. package/vitest.config.js +0 -23
@@ -47,7 +47,7 @@ const vitestArgs = ["vitest", "run"];
47
47
  if (testPath) {
48
48
  vitestArgs.push(testPath);
49
49
  } else {
50
- vitestArgs.push("test/e2e");
50
+ vitestArgs.push(...["--config", "./vitest.config.e2e.ts"]);
51
51
  }
52
52
 
53
53
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typespec/http-client-js",
3
- "version": "0.3.0-dev.0",
3
+ "version": "0.3.0-dev.2",
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",
@@ -26,30 +26,30 @@
26
26
  "license": "MIT",
27
27
  "description": "TypeSpec library for emitting Http Client libraries for JavaScript/TypeScript",
28
28
  "peerDependencies": {
29
- "@typespec/compiler": "^0.67.0 || >=0.68.0-dev <0.68.0",
30
- "@typespec/http": "^0.67.0 || >=0.68.0-dev <0.68.0",
31
- "@typespec/rest": "^0.67.0 || >=0.68.0-dev <0.68.0"
29
+ "@typespec/compiler": "^0.67.1 || >=0.68.0-dev <0.68.0",
30
+ "@typespec/http": "^0.67.1 || >=0.68.0-dev <0.68.0",
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.0 || >=0.68.0-dev <0.68.0",
42
41
  "@alloy-js/babel-preset": "^0.2.0",
43
42
  "@babel/cli": "^7.24.8",
44
43
  "@babel/core": "^7.26.9",
45
44
  "@rollup/plugin-babel": "^6.0.4",
46
45
  "@types/yargs": "~17.0.33",
47
- "@typespec/http-specs": "^0.1.0-alpha.13 || >=0.1.0-alpha.14-dev <0.1.0-alpha.14",
46
+ "@typespec/http": "^0.67.1 || >=0.68.0-dev <0.68.0",
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
- "@typespec/versioning": "^0.67.0 || >=0.68.0-dev <0.68.0",
50
+ "@typespec/versioning": "^0.67.1 || >=0.68.0-dev <0.68.0",
51
51
  "@vitest/ui": "^3.0.7",
52
- "picocolors": "~1.1.1",
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",
@@ -57,11 +57,11 @@
57
57
  "inquirer": "^12.2.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
63
  "vitest": "^3.0.7",
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:scenarios": "vitest run scenarios.test.ts",
77
- "test": "npm run test:scenarios",
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"
@@ -1,6 +1,5 @@
1
1
  import * as ay from "@alloy-js/core";
2
2
  import * as ts from "@alloy-js/typescript";
3
- import { ClassDeclaration } from "@alloy-js/typescript";
4
3
  import { $ } from "@typespec/compiler/experimental/typekit";
5
4
  import { ClassMethod } from "@typespec/emitter-framework/typescript";
6
5
  import * as cl from "@typespec/http-client";
@@ -54,19 +53,19 @@ export function ClientClass(props: ClientClassProps) {
54
53
  const subClients = props.client.subClients;
55
54
  const operations = props.client.operations;
56
55
  return (
57
- <ClassDeclaration export name={clientName} refkey={clientClassRef}>
58
- <ay.StatementList>
56
+ <ts.ClassDeclaration export name={clientName} refkey={clientClassRef}>
57
+ <ay.List hardline>
59
58
  <ts.ClassField
60
59
  name="context"
61
60
  jsPrivate
62
61
  refkey={contextMemberRef}
63
62
  type={contextDeclarationRef}
64
63
  />
65
- <ay.For each={subClients} hardline joiner=";">
64
+ <ay.For each={subClients} hardline semicolon>
66
65
  {(subClient) => <SubClientClassField client={subClient} />}
67
66
  </ay.For>
68
- <ClientConstructor client={props.client} />;<br />
69
- <ay.For each={operations} hardline joiner=";">
67
+ <ClientConstructor client={props.client} />
68
+ <ay.For each={operations} hardline semicolon>
70
69
  {(op) => {
71
70
  const parameters = getOperationParameters(op.httpOperation);
72
71
  const args = Object.keys(parameters).map((p) => p);
@@ -89,8 +88,8 @@ export function ClientClass(props: ClientClassProps) {
89
88
  );
90
89
  }}
91
90
  </ay.For>
92
- </ay.StatementList>
93
- </ClassDeclaration>
91
+ </ay.List>
92
+ </ts.ClassDeclaration>
94
93
  );
95
94
  }
96
95
 
package/src/emitter.tsx CHANGED
@@ -33,7 +33,9 @@ export async function $onEmit(context: EmitContext<JsClientEmitterOptions>) {
33
33
  <ay.SourceDirectory path="models">
34
34
  <ts.BarrelFile export="models" />
35
35
  <Models />
36
- <ModelSerializers />
36
+ <ay.SourceDirectory path="internal">
37
+ <ModelSerializers />
38
+ </ay.SourceDirectory>
37
39
  </ay.SourceDirectory>
38
40
  <ay.SourceDirectory path="api">
39
41
  <OperationsDirectory />
@@ -161,7 +161,7 @@ describe("Encode.Bytes", () => {
161
161
  },
162
162
  });
163
163
 
164
- it("should test default encode (base64) for bytes in JSON body response", async () => {
164
+ it.skip("should test default encode (base64) for bytes in JSON body response", async () => {
165
165
  const response = await client.default_();
166
166
  expect(response).toStrictEqual(encodedTestString);
167
167
  });
@@ -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
  }
@@ -77,6 +77,7 @@ export class DemoServiceClient {
77
77
  }
78
78
  export class WidgetsClient {
79
79
  #context: WidgetsClientContext;
80
+
80
81
  constructor(endpoint: string, options?: WidgetsClientOptions) {
81
82
  this.#context = createWidgetsClientContext(endpoint, options);
82
83
  }
@@ -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 "./models.js";
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 "./models.js";
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
  }