@typespec/http-client-js 0.3.0-dev.1 → 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 (59) hide show
  1. package/CHANGELOG.md +0 -3
  2. package/eng/scripts/run-e2e-tests.js +1 -1
  3. package/package.json +11 -9
  4. package/test/e2e/http/type/model/visibility/main.test.ts +2 -2
  5. package/test/scenarios/additional-properties/extends.md +2 -2
  6. package/test/scenarios/additional-properties/spread.md +2 -2
  7. package/test/scenarios/auth/basic_auth.md +1 -0
  8. package/test/scenarios/auth/bearer.md +1 -0
  9. package/test/scenarios/auth/client_parameters.md +1 -0
  10. package/test/scenarios/auth/key_credential.md +1 -0
  11. package/test/scenarios/auth/sub_client_override.md +2 -0
  12. package/test/scenarios/client/dotted_namespace.md +1 -0
  13. package/test/scenarios/client/global_namespace.md +1 -0
  14. package/test/scenarios/client/multiple_top_level_clients.md +2 -0
  15. package/test/scenarios/client/nested_client.md +1 -0
  16. package/test/scenarios/encoding/bytes_json_property.md +1 -1
  17. package/test/scenarios/encoding/bytes_nullable.md +2 -2
  18. package/test/scenarios/encoding/model_with_bytes_property.md +1 -1
  19. package/test/scenarios/http-operations/basic-response.md +1 -1
  20. package/test/scenarios/http-operations/basic.md +2 -1
  21. package/test/scenarios/http-operations/optional-request-body.md +1 -1
  22. package/test/scenarios/http-operations/query-parameter.md +41 -0
  23. package/test/scenarios/http-operations/scalar-payload.md +1 -1
  24. package/test/scenarios/http-operations/with-parameters.md +1 -0
  25. package/test/scenarios/models/inheritance_2_discriminators.md +2 -2
  26. package/test/scenarios/models/inheritance_discriminator.md +4 -4
  27. package/test/scenarios/models/model_additional_properties.md +2 -2
  28. package/test/scenarios/models/model_extends.md +4 -4
  29. package/test/scenarios/models/model_spread.md +2 -2
  30. package/test/scenarios/models/property_references_property.md +4 -4
  31. package/test/scenarios/multipart/file_content_type.md +2 -2
  32. package/test/scenarios/operation-parameters/body_root_anonymous.md +1 -0
  33. package/test/scenarios/operation-parameters/constant_as_optional.md +1 -0
  34. package/test/scenarios/operation-parameters/default_value_as_optional.md +1 -0
  35. package/test/scenarios/operation-parameters/no_content_type.md +1 -0
  36. package/test/scenarios/operation-parameters/no_parameters.md +1 -0
  37. package/test/scenarios/operation-parameters/only_optional.md +1 -0
  38. package/test/scenarios/operation-parameters/only_required.md +1 -0
  39. package/test/scenarios/operation-parameters/reserved_names.md +1 -0
  40. package/test/scenarios/operation-parameters/spread_body.md +1 -0
  41. package/test/scenarios/operation-parameters/spread_with_nested.md +1 -0
  42. package/test/scenarios/operation-parameters/union_body.md +2 -1
  43. package/test/scenarios/operation-parameters/with_body_property.md +1 -0
  44. package/test/scenarios/operation-parameters/with_body_root.md +1 -0
  45. package/test/scenarios/serializers/arrays.md +6 -6
  46. package/test/scenarios/serializers/basic_model.md +4 -4
  47. package/test/scenarios/serializers/basic_model_wire_name.md +3 -3
  48. package/test/scenarios/serializers/discriminated_union.md +4 -4
  49. package/test/scenarios/serializers/discriminated_union_spread.md +5 -5
  50. package/test/scenarios/serializers/model_date_time.md +5 -5
  51. package/test/scenarios/serializers/polymorphic_single_level_inheritance.md +6 -6
  52. package/test/scenarios/serializers/property_references_property.md +2 -2
  53. package/test/scenarios/serializers/record.md +4 -4
  54. package/test/scenarios/serializers/spread.md +1 -1
  55. package/test/scenarios/serializers/string_union.md +1 -1
  56. package/test/scenarios.test.ts +11 -3
  57. package/vitest.config.e2e.ts +16 -0
  58. package/vitest.config.ts +26 -0
  59. package/vitest.config.js +0 -23
package/CHANGELOG.md CHANGED
@@ -1,7 +1,5 @@
1
1
  # Changelog - @typespec/http-client-js
2
2
 
3
-
4
-
5
3
  ## 0.2.0
6
4
 
7
5
  ### Deprecations
@@ -18,4 +16,3 @@
18
16
  - [#6390](https://github.com/microsoft/typespec/pull/6390) Fix Multipart handling for model with @body
19
17
  - [#6348](https://github.com/microsoft/typespec/pull/6348) handle model property references in union types correctly
20
18
  - [#6286](https://github.com/microsoft/typespec/pull/6286) Replace @discriminator union with @discriminated
21
-
@@ -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.1",
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",
@@ -31,25 +31,25 @@
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
43
  "@babel/core": "^7.26.9",
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
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"
@@ -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
  }
@@ -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
  }
@@ -64,6 +64,7 @@ export interface SendOptions 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
  }
@@ -73,7 +74,7 @@ export class TestClient {
73
74
  }
74
75
  ```
75
76
 
76
- ```ts src/models/serializers.ts function jsonEnumsOnlyCasesToTransportTransform
77
+ ```ts src/models/internal/serializers.ts function jsonEnumsOnlyCasesToTransportTransform
77
78
  export function jsonEnumsOnlyCasesToTransportTransform(input_?: EnumsOnlyCases | null): any {
78
79
  if (!input_) {
79
80
  return input_ as any;
@@ -57,6 +57,7 @@ export interface CreateOptions extends OperationOptions {
57
57
  ```ts src/testClient.ts class TestClient
58
58
  export class TestClient {
59
59
  #context: TestClientContext;
60
+
60
61
  constructor(endpoint: string, options?: TestClientOptions) {
61
62
  this.#context = createTestClientContext(endpoint, options);
62
63
  }
@@ -59,6 +59,7 @@ export interface CreateOptions extends OperationOptions {
59
59
  ```ts src/testClient.ts class TestClient
60
60
  export class TestClient {
61
61
  #context: TestClientContext;
62
+
62
63
  constructor(endpoint: string, options?: TestClientOptions) {
63
64
  this.#context = createTestClientContext(endpoint, options);
64
65
  }
@@ -35,7 +35,7 @@ export interface Foo {
35
35
 
36
36
  The generated transformation functions iterate over `int32[]` values, but since **no actual transformation occurs**, this code could be **optimized away**.
37
37
 
38
- ```ts src/models/serializers.ts function jsonArrayInt32ToTransportTransform
38
+ ```ts src/models/internal/serializers.ts function jsonArrayInt32ToTransportTransform
39
39
  export function jsonArrayInt32ToTransportTransform(items_?: Array<number> | null): any {
40
40
  if (!items_) {
41
41
  return items_ as any;
@@ -55,7 +55,7 @@ export function jsonArrayInt32ToTransportTransform(items_?: Array<number> | null
55
55
 
56
56
  Uses `jsonArrayInt32ToTransportTransform` for `myValues`, though this could be optimized by **directly passing the array** instead of applying a redundant transformation function.
57
57
 
58
- ```ts src/models/serializers.ts function jsonFooToTransportTransform
58
+ ```ts src/models/internal/serializers.ts function jsonFooToTransportTransform
59
59
  export function jsonFooToTransportTransform(input_?: Foo | null): any {
60
60
  if (!input_) {
61
61
  return input_ as any;
@@ -92,7 +92,7 @@ export async function foo(client: ClientContext, options?: FooOptions): Promise<
92
92
 
93
93
  Again, the transformation logic is redundant for primitive types. Instead of generating a function, the deserializer could **use the array directly**.
94
94
 
95
- ```ts src/models/serializers.ts function jsonArrayInt32ToApplicationTransform
95
+ ```ts src/models/internal/serializers.ts function jsonArrayInt32ToApplicationTransform
96
96
  export function jsonArrayInt32ToApplicationTransform(items_?: any): Array<number> {
97
97
  if (!items_) {
98
98
  return items_ as any;
@@ -112,7 +112,7 @@ export function jsonArrayInt32ToApplicationTransform(items_?: any): Array<number
112
112
 
113
113
  Uses the same unnecessary transformation for `myValues`. Optimizing the pipeline could **eliminate this step** for primitive arrays.
114
114
 
115
- ```ts src/models/serializers.ts function jsonFooToApplicationTransform
115
+ ```ts src/models/internal/serializers.ts function jsonFooToApplicationTransform
116
116
  export function jsonFooToApplicationTransform(input_?: any): Foo {
117
117
  if (!input_) {
118
118
  return input_ as any;
@@ -164,7 +164,7 @@ export interface Bar {
164
164
 
165
165
  Uses `jsonArrayBarToTransportTransform` to serialize each `Bar` instance inside `myValues`, ensuring proper transformation of complex objects.
166
166
 
167
- ```ts src/models/serializers.ts function jsonFooToTransportTransform
167
+ ```ts src/models/internal/serializers.ts function jsonFooToTransportTransform
168
168
  export function jsonFooToTransportTransform(input_?: Foo | null): any {
169
169
  if (!input_) {
170
170
  return input_ as any;
@@ -179,7 +179,7 @@ export function jsonFooToTransportTransform(input_?: Foo | null): any {
179
179
 
180
180
  Similarly, the deserializer converts each `Bar` instance in `myValues` back into an application model using `jsonArrayBarToApplicationTransform`.
181
181
 
182
- ```ts src/models/serializers.ts function jsonFooToApplicationTransform
182
+ ```ts src/models/internal/serializers.ts function jsonFooToApplicationTransform
183
183
  export function jsonFooToApplicationTransform(input_?: any): Foo {
184
184
  if (!input_) {
185
185
  return input_ as any;
@@ -29,7 +29,7 @@ export interface Foo {
29
29
 
30
30
  This function should correctly transform a Foo instance into a transport-friendly format, ensuring all properties are properly mapped.
31
31
 
32
- ```ts src/models/serializers.ts function jsonFooToTransportTransform
32
+ ```ts src/models/internal/serializers.ts function jsonFooToTransportTransform
33
33
  export function jsonFooToTransportTransform(input_?: Foo | null): any {
34
34
  if (!input_) {
35
35
  return input_ as any;
@@ -45,7 +45,7 @@ export function jsonFooToTransportTransform(input_?: Foo | null): any {
45
45
 
46
46
  This function should correctly reconstruct a Foo instance from a transport-friendly representation, ensuring all properties are properly mapped back.
47
47
 
48
- ```ts src/models/serializers.ts function jsonFooToApplicationTransform
48
+ ```ts src/models/internal/serializers.ts function jsonFooToApplicationTransform
49
49
  export function jsonFooToApplicationTransform(input_?: any): Foo {
50
50
  if (!input_) {
51
51
  return input_ as any;
@@ -82,7 +82,7 @@ op foo(): Foo | Bar;
82
82
 
83
83
  This function should transform Foo into a transport-friendly format while ensuring that the bar property is serialized using the jsonBarToTransportTransform function.
84
84
 
85
- ```ts src/models/serializers.ts function jsonFooToTransportTransform
85
+ ```ts src/models/internal/serializers.ts function jsonFooToTransportTransform
86
86
  export function jsonFooToTransportTransform(input_?: Foo | null): any {
87
87
  if (!input_) {
88
88
  return input_ as any;
@@ -99,7 +99,7 @@ export function jsonFooToTransportTransform(input_?: Foo | null): any {
99
99
 
100
100
  This function should transform a Bar instance into its transport format, correctly mapping its properties.
101
101
 
102
- ```ts src/models/serializers.ts function jsonBarToTransportTransform
102
+ ```ts src/models/internal/serializers.ts function jsonBarToTransportTransform
103
103
  export function jsonBarToTransportTransform(input_?: Bar | null): any {
104
104
  if (!input_) {
105
105
  return input_ as any;
@@ -12,7 +12,7 @@ op foo(): Foo;
12
12
 
13
13
  ## TypeScript
14
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/serializers.ts`.
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
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
17
  should return these properties with the same name as the generated model (camelCase)
18
18
 
@@ -23,7 +23,7 @@ export interface Foo {
23
23
  }
24
24
  ```
25
25
 
26
- ```ts src/models/serializers.ts function jsonFooToTransportTransform
26
+ ```ts src/models/internal/serializers.ts function jsonFooToTransportTransform
27
27
  export function jsonFooToTransportTransform(input_?: Foo | null): any {
28
28
  if (!input_) {
29
29
  return input_ as any;
@@ -35,7 +35,7 @@ export function jsonFooToTransportTransform(input_?: Foo | null): any {
35
35
  }
36
36
  ```
37
37
 
38
- ```ts src/models/serializers.ts function jsonFooToApplicationTransform
38
+ ```ts src/models/internal/serializers.ts function jsonFooToApplicationTransform
39
39
  export function jsonFooToApplicationTransform(input_?: any): Foo {
40
40
  if (!input_) {
41
41
  return input_ as any;
@@ -31,7 +31,7 @@ op put(@body body: WidgetData): void;
31
31
 
32
32
  ## Typescript
33
33
 
34
- ```ts src/models/serializers.ts function jsonWidgetDataToTransportTransform
34
+ ```ts src/models/internal/serializers.ts function jsonWidgetDataToTransportTransform
35
35
  export function jsonWidgetDataToTransportTransform(input_?: WidgetData | null): any {
36
36
  if (!input_) {
37
37
  return input_ as any;
@@ -40,7 +40,7 @@ export function jsonWidgetDataToTransportTransform(input_?: WidgetData | null):
40
40
  }
41
41
  ```
42
42
 
43
- ```ts src/models/serializers.ts function jsonWidgetDataToApplicationTransform
43
+ ```ts src/models/internal/serializers.ts function jsonWidgetDataToApplicationTransform
44
44
  export function jsonWidgetDataToApplicationTransform(input_?: any): WidgetData {
45
45
  if (!input_) {
46
46
  return input_ as any;
@@ -49,7 +49,7 @@ export function jsonWidgetDataToApplicationTransform(input_?: any): WidgetData {
49
49
  }
50
50
  ```
51
51
 
52
- ```ts src/models/serializers.ts function jsonWidgetDataToTransportDiscriminator
52
+ ```ts src/models/internal/serializers.ts function jsonWidgetDataToTransportDiscriminator
53
53
  export function jsonWidgetDataToTransportDiscriminator(input_?: WidgetData): any {
54
54
  if (!input_) {
55
55
  return input_ as any;
@@ -67,7 +67,7 @@ export function jsonWidgetDataToTransportDiscriminator(input_?: WidgetData): any
67
67
  }
68
68
  ```
69
69
 
70
- ```ts src/models/serializers.ts function jsonWidgetDataToApplicationDiscriminator
70
+ ```ts src/models/internal/serializers.ts function jsonWidgetDataToApplicationDiscriminator
71
71
  export function jsonWidgetDataToApplicationDiscriminator(input_?: any): WidgetData {
72
72
  if (!input_) {
73
73
  return input_ as any;
@@ -39,7 +39,7 @@ op put(@body body: SpreadRecordForDiscriminatedUnion): void;
39
39
 
40
40
  ## Typescript
41
41
 
42
- ```ts src/models/serializers.ts function jsonSpreadRecordForDiscriminatedUnionToTransportTransform
42
+ ```ts src/models/internal/serializers.ts function jsonSpreadRecordForDiscriminatedUnionToTransportTransform
43
43
  export function jsonSpreadRecordForDiscriminatedUnionToTransportTransform(
44
44
  input_?: SpreadRecordForDiscriminatedUnion | null,
45
45
  ): any {
@@ -53,7 +53,7 @@ export function jsonSpreadRecordForDiscriminatedUnionToTransportTransform(
53
53
  }
54
54
  ```
55
55
 
56
- ```ts src/models/serializers.ts function jsonSpreadRecordForDiscriminatedUnionToApplicationTransform
56
+ ```ts src/models/internal/serializers.ts function jsonSpreadRecordForDiscriminatedUnionToApplicationTransform
57
57
  export function jsonSpreadRecordForDiscriminatedUnionToApplicationTransform(
58
58
  input_?: any,
59
59
  ): SpreadRecordForDiscriminatedUnion {
@@ -69,7 +69,7 @@ export function jsonSpreadRecordForDiscriminatedUnionToApplicationTransform(
69
69
  }
70
70
  ```
71
71
 
72
- ```ts src/models/serializers.ts function jsonWidgetDataToTransportTransform
72
+ ```ts src/models/internal/serializers.ts function jsonWidgetDataToTransportTransform
73
73
  export function jsonWidgetDataToTransportTransform(input_?: WidgetData | null): any {
74
74
  if (!input_) {
75
75
  return input_ as any;
@@ -78,7 +78,7 @@ export function jsonWidgetDataToTransportTransform(input_?: WidgetData | null):
78
78
  }
79
79
  ```
80
80
 
81
- ```ts src/models/serializers.ts function jsonWidgetDataToApplicationDiscriminator
81
+ ```ts src/models/internal/serializers.ts function jsonWidgetDataToApplicationDiscriminator
82
82
  export function jsonWidgetDataToApplicationDiscriminator(input_?: any): WidgetData {
83
83
  if (!input_) {
84
84
  return input_ as any;
@@ -96,7 +96,7 @@ export function jsonWidgetDataToApplicationDiscriminator(input_?: any): WidgetDa
96
96
  }
97
97
  ```
98
98
 
99
- ```ts src/models/serializers.ts function jsonWidgetDataToTransportDiscriminator
99
+ ```ts src/models/internal/serializers.ts function jsonWidgetDataToTransportDiscriminator
100
100
  export function jsonWidgetDataToTransportDiscriminator(input_?: WidgetData): any {
101
101
  if (!input_) {
102
102
  return input_ as any;
@@ -14,7 +14,7 @@ op foo(): Foo;
14
14
 
15
15
  ## TypeScript
16
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/serializers.ts`.
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
18
  The generated model should have a property `createdOn` of type `Date`, the generated serializer `jsonFooToTransportTransform` should convert a Date into a string.
19
19
 
20
20
  ```ts src/models/models.ts interface Foo
@@ -23,7 +23,7 @@ export interface Foo {
23
23
  }
24
24
  ```
25
25
 
26
- ```ts src/models/serializers.ts function jsonFooToTransportTransform
26
+ ```ts src/models/internal/serializers.ts function jsonFooToTransportTransform
27
27
  export function jsonFooToTransportTransform(item: Foo): any {
28
28
  return {
29
29
  created_on: dateRfc3339Serializer(item.createdOn),
@@ -31,7 +31,7 @@ export function jsonFooToTransportTransform(item: Foo): any {
31
31
  }
32
32
  ```
33
33
 
34
- ```ts src/models/serializers.ts function jsonFooToApplicationTransform
34
+ ```ts src/models/internal/serializers.ts function jsonFooToApplicationTransform
35
35
  export function jsonFooToApplicationTransform(item: any): Foo {
36
36
  return {
37
37
  createdOn: dateDeserializer(item.created_on),
@@ -53,10 +53,10 @@ op foo(): Foo;
53
53
 
54
54
  ## TypeScript
55
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/serializers.ts`.
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
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
58
 
59
- ```ts src/models/serializers.ts function jsonFooToTransportTransform
59
+ ```ts src/models/internal/serializers.ts function jsonFooToTransportTransform
60
60
  export function jsonFooToTransportTransform(item: Foo): any {
61
61
  return {
62
62
  created_on: dateRfc7231Serializer(item.createdOn),
@@ -46,7 +46,7 @@ op getModel(): Bird;
46
46
  **Expectation for `jsonBirdToTransportDiscriminator`:**
47
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
48
 
49
- ```ts src/models/serializers.ts function jsonBirdToTransportDiscriminator
49
+ ```ts src/models/internal/serializers.ts function jsonBirdToTransportDiscriminator
50
50
  export function jsonBirdToTransportDiscriminator(input_?: Bird): any {
51
51
  if (!input_) {
52
52
  return input_ as any;
@@ -75,7 +75,7 @@ export function jsonBirdToTransportDiscriminator(input_?: Bird): any {
75
75
  **Expectation for `jsonBirdToTransportTransform`:**
76
76
  This function should transform a basic `Bird` instance by mapping its core properties (`kind` and `wingspan`) to the transport format.
77
77
 
78
- ```ts src/models/serializers.ts function jsonBirdToTransportTransform
78
+ ```ts src/models/internal/serializers.ts function jsonBirdToTransportTransform
79
79
  export function jsonBirdToTransportTransform(input_?: Bird | null): any {
80
80
  if (!input_) {
81
81
  return input_ as any;
@@ -91,7 +91,7 @@ export function jsonBirdToTransportTransform(input_?: Bird | null): any {
91
91
  **Expectation for `jsonSeaGullToTransportTransform`:**
92
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
93
 
94
- ```ts src/models/serializers.ts function jsonSeaGullToTransportTransform
94
+ ```ts src/models/internal/serializers.ts function jsonSeaGullToTransportTransform
95
95
  export function jsonSeaGullToTransportTransform(input_?: SeaGull | null): any {
96
96
  if (!input_) {
97
97
  return input_ as any;
@@ -106,7 +106,7 @@ export function jsonSeaGullToTransportTransform(input_?: SeaGull | null): any {
106
106
  **Expectation for `jsonSparrowToTransportTransform`:**
107
107
  Similarly, the serializer for a `Sparrow` instance should build upon the base Bird transformation and add the `kind` property accordingly.
108
108
 
109
- ```ts src/models/serializers.ts function jsonSparrowToTransportTransform
109
+ ```ts src/models/internal/serializers.ts function jsonSparrowToTransportTransform
110
110
  export function jsonSparrowToTransportTransform(input_?: Sparrow | null): any {
111
111
  if (!input_) {
112
112
  return input_ as any;
@@ -121,7 +121,7 @@ export function jsonSparrowToTransportTransform(input_?: Sparrow | null): any {
121
121
  **Expectation for `jsonGooseToTransportTransform`:**
122
122
  This function should transform a `Goose` instance by reusing the base Bird transformation and explicitly setting the `kind` property.
123
123
 
124
- ```ts src/models/serializers.ts function jsonGooseToTransportTransform
124
+ ```ts src/models/internal/serializers.ts function jsonGooseToTransportTransform
125
125
  export function jsonGooseToTransportTransform(input_?: Goose | null): any {
126
126
  if (!input_) {
127
127
  return input_ as any;
@@ -141,7 +141,7 @@ The serializer for an `Eagle` instance is more complex due to additional propert
141
141
  - Transform the `hate` property (a primitive Record of `Bird` instances) using `jsonRecordBirdToTransportTransform`, and
142
142
  - Transform the `partner` property (a single `Bird` instance) using `jsonBirdToApplicationTransform`.
143
143
 
144
- ```ts src/models/serializers.ts function jsonEagleToTransportTransform
144
+ ```ts src/models/internal/serializers.ts function jsonEagleToTransportTransform
145
145
  export function jsonEagleToTransportTransform(input_?: Eagle | null): any {
146
146
  if (!input_) {
147
147
  return input_ as any;
@@ -43,7 +43,7 @@ Validates that the serializer generates the correct serialization logic for:
43
43
  - Direct property references (`title?: TodoItem.title`)
44
44
  - Nullable property references (`assignedTo?: TodoItem.assignedTo | null`)
45
45
 
46
- ```ts src/models/serializers.ts function jsonTodoItemPatchToTransportTransform
46
+ ```ts src/models/internal/serializers.ts function jsonTodoItemPatchToTransportTransform
47
47
  export function jsonTodoItemPatchToTransportTransform(input_?: TodoItemPatch | null): any {
48
48
  if (!input_) {
49
49
  return input_ as any;
@@ -59,7 +59,7 @@ export function jsonTodoItemPatchToTransportTransform(input_?: TodoItemPatch | n
59
59
 
60
60
  Validates the deserialization logic maintains type consistency when converting from transport to application models.
61
61
 
62
- ```ts src/models/serializers.ts function jsonTodoItemPatchToApplicationTransform
62
+ ```ts src/models/internal/serializers.ts function jsonTodoItemPatchToApplicationTransform
63
63
  export function jsonTodoItemPatchToApplicationTransform(input_?: any): TodoItemPatch {
64
64
  if (!input_) {
65
65
  return input_ as any;
@@ -20,7 +20,7 @@ export interface Foo {
20
20
  }
21
21
  ```
22
22
 
23
- ```ts src/models/serializers.ts function jsonFooToTransportTransform
23
+ ```ts src/models/internal/serializers.ts function jsonFooToTransportTransform
24
24
  export function jsonFooToTransportTransform(input_?: Foo | null): any {
25
25
  if (!input_) {
26
26
  return input_ as any;
@@ -31,7 +31,7 @@ export function jsonFooToTransportTransform(input_?: Foo | null): any {
31
31
  }
32
32
  ```
33
33
 
34
- ```ts src/models/serializers.ts function jsonFooToApplicationTransform
34
+ ```ts src/models/internal/serializers.ts function jsonFooToApplicationTransform
35
35
  export function jsonFooToApplicationTransform(input_?: any): Foo {
36
36
  if (!input_) {
37
37
  return input_ as any;
@@ -74,7 +74,7 @@ export interface Bar {
74
74
  }
75
75
  ```
76
76
 
77
- ```ts src/models/serializers.ts function jsonFooToTransportTransform
77
+ ```ts src/models/internal/serializers.ts function jsonFooToTransportTransform
78
78
  export function jsonFooToTransportTransform(input_?: Foo | null): any {
79
79
  if (!input_) {
80
80
  return input_ as any;
@@ -85,7 +85,7 @@ export function jsonFooToTransportTransform(input_?: Foo | null): any {
85
85
  }
86
86
  ```
87
87
 
88
- ```ts src/models/serializers.ts function jsonFooToApplicationTransform
88
+ ```ts src/models/internal/serializers.ts function jsonFooToApplicationTransform
89
89
  export function jsonFooToApplicationTransform(input_?: any): Foo {
90
90
  if (!input_) {
91
91
  return input_ as any;
@@ -31,7 +31,7 @@ op spreadWithMultipleParameters(...MultipleRequestParameters): NoContentResponse
31
31
 
32
32
  ## Typescript
33
33
 
34
- When spreading a model an anonymous model created in the type graph, the emitted operation should have the serializer expression inline. No serializer function for this operation is expected in src/models/serializers.ts
34
+ When spreading a model an anonymous model created in the type graph, the emitted operation should have the serializer expression inline. No serializer function for this operation is expected in src/models/internal/serializers.ts
35
35
 
36
36
  ```ts src/api/testClientOperations.ts function spreadWithMultipleParameters
37
37
  export async function spreadWithMultipleParameters(
@@ -43,7 +43,7 @@ export async function unionEnumName(
43
43
  }
44
44
  ```
45
45
 
46
- ```ts src/models/serializers.ts function jsonServerExtensibleEnumToTransportTransform
46
+ ```ts src/models/internal/serializers.ts function jsonServerExtensibleEnumToTransportTransform
47
47
  export function jsonServerExtensibleEnumToTransportTransform(
48
48
  input_?: ServerExtensibleEnum | null,
49
49
  ): any {
@@ -3,16 +3,24 @@ import {
3
3
  createTypeScriptExtractorConfig,
4
4
  executeScenarios,
5
5
  } from "@typespec/emitter-framework/testing";
6
- import { join } from "path";
6
+ import { dirname, join } from "path";
7
+ import { fileURLToPath } from "url";
7
8
  import { HttpClientJavascriptEmitterTestLibrary } from "../src/testing/index.js";
8
9
 
10
+ const __filename = fileURLToPath(import.meta.url);
11
+ const __dirname = dirname(__filename);
12
+
9
13
  const tsExtractorConfig = createTypeScriptExtractorConfig();
10
14
  const snipperExtractor = createSnipperExtractor(tsExtractorConfig);
11
15
 
16
+ // Construct the test path relative to this file.
17
+ const scenarioPath = join(__dirname, "scenarios");
18
+ const outputPath = join("tsp-output", "@typespec", "http-client-js");
19
+
12
20
  await executeScenarios(
13
21
  HttpClientJavascriptEmitterTestLibrary,
14
22
  tsExtractorConfig,
15
- "./test/scenarios",
16
- join("tsp-output", "@typespec/http-client-js"),
23
+ scenarioPath,
24
+ outputPath,
17
25
  snipperExtractor,
18
26
  );
@@ -0,0 +1,16 @@
1
+ import { defineConfig } from "vitest/config";
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ environment: "node",
6
+ isolate: false,
7
+ coverage: {
8
+ reporter: ["cobertura", "json", "text"],
9
+ },
10
+ outputFile: {
11
+ junit: "./test-results.xml",
12
+ },
13
+
14
+ include: ["test/e2e/**/*.test.ts"],
15
+ },
16
+ });
@@ -0,0 +1,26 @@
1
+ import { babel } from "@rollup/plugin-babel";
2
+ import { defineConfig, mergeConfig } from "vitest/config";
3
+ import { defaultTypeSpecVitestConfig } from "../../vitest.workspace.js";
4
+
5
+ export default mergeConfig(
6
+ defaultTypeSpecVitestConfig,
7
+ defineConfig({
8
+ test: {
9
+ include: ["test/**/*.test.ts"],
10
+ exclude: ["test/e2e/**/*"],
11
+ passWithNoTests: true,
12
+ },
13
+ esbuild: {
14
+ jsx: "preserve",
15
+ sourcemap: "both",
16
+ },
17
+ plugins: [
18
+ babel({
19
+ sourceMaps: true,
20
+ babelHelpers: "bundled",
21
+ extensions: [".ts", ".tsx"],
22
+ presets: ["@babel/preset-typescript", "@alloy-js/babel-preset"],
23
+ }),
24
+ ],
25
+ }),
26
+ );
package/vitest.config.js DELETED
@@ -1,23 +0,0 @@
1
- import { babel } from "@rollup/plugin-babel";
2
- import { defineConfig } from "vitest/config";
3
-
4
- export default defineConfig({
5
- test: {
6
- include: ["test/**/*.test.ts", "test/**/*.test.tsx"],
7
- exclude: ["test/**/*.d.ts"],
8
- passWithNoTests: true,
9
- },
10
- esbuild: {
11
- jsx: "preserve",
12
- sourcemap: "both",
13
- },
14
- plugins: [
15
- babel({
16
- inputSourceMap: true,
17
- sourceMaps: "both",
18
- babelHelpers: "bundled",
19
- extensions: [".ts", ".tsx"],
20
- presets: ["@babel/preset-typescript", "@alloy-js/babel-preset"],
21
- }),
22
- ],
23
- });