typespec-typescript-emitter 1.2.0 → 2.0.1

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 (166) hide show
  1. package/.husky/pre-commit +2 -1
  2. package/.prettierignore +2 -1
  3. package/CHANGELOG.md +19 -24
  4. package/CODE_OF_CONDUCT.md +128 -0
  5. package/README.md +362 -219
  6. package/dist/src/emit_routedTypemap.d.ts +4 -0
  7. package/dist/src/emit_routedTypemap.js +83 -0
  8. package/dist/src/emit_routedTypemap.js.map +1 -0
  9. package/dist/src/emit_routes.d.ts +3 -2
  10. package/dist/src/emit_routes.js +73 -47
  11. package/dist/src/emit_routes.js.map +1 -1
  12. package/dist/src/emit_types.d.ts +3 -9
  13. package/dist/src/emit_types.js +109 -74
  14. package/dist/src/emit_types.js.map +1 -1
  15. package/dist/src/emitter.d.ts +2 -6
  16. package/dist/src/emitter.js +18 -76
  17. package/dist/src/emitter.js.map +1 -1
  18. package/dist/src/helpers/appendableString.d.ts +15 -0
  19. package/dist/src/helpers/appendableString.js +41 -0
  20. package/dist/src/helpers/appendableString.js.map +1 -0
  21. package/dist/src/helpers/arrays.d.ts +3 -0
  22. package/dist/src/helpers/arrays.js +23 -0
  23. package/dist/src/helpers/arrays.js.map +1 -0
  24. package/dist/src/{helper_autogenerateWarning.d.ts → helpers/autogenerateWarning.d.ts} +1 -1
  25. package/dist/src/{helper_autogenerateWarning.js → helpers/autogenerateWarning.js} +1 -2
  26. package/dist/src/helpers/autogenerateWarning.js.map +1 -0
  27. package/dist/src/helpers/buildTypeMap.d.ts +12 -0
  28. package/dist/src/helpers/buildTypeMap.js +44 -0
  29. package/dist/src/helpers/buildTypeMap.js.map +1 -0
  30. package/dist/src/helpers/diagnostics.d.ts +4 -0
  31. package/dist/src/helpers/diagnostics.js +15 -0
  32. package/dist/src/helpers/diagnostics.js.map +1 -0
  33. package/dist/src/helpers/getImports.d.ts +2 -0
  34. package/dist/src/helpers/getImports.js +3 -0
  35. package/dist/src/helpers/getImports.js.map +1 -0
  36. package/dist/src/helpers/namespaces.d.ts +4 -0
  37. package/dist/src/helpers/namespaces.js +14 -0
  38. package/dist/src/helpers/namespaces.js.map +1 -0
  39. package/dist/src/helpers/visibilityHelperFile.d.ts +4 -0
  40. package/dist/src/helpers/visibilityHelperFile.js +57 -0
  41. package/dist/src/helpers/visibilityHelperFile.js.map +1 -0
  42. package/dist/src/lib.d.ts +4 -1
  43. package/dist/src/lib.js +14 -3
  44. package/dist/src/lib.js.map +1 -1
  45. package/dist/src/parseOptions.d.ts +8 -0
  46. package/dist/src/parseOptions.js +26 -0
  47. package/dist/src/parseOptions.js.map +1 -0
  48. package/dist/src/resolve/Resolvable.d.ts +32 -0
  49. package/dist/src/resolve/Resolvable.js +180 -0
  50. package/dist/src/resolve/Resolvable.js.map +1 -0
  51. package/dist/src/resolve/Resolvable_helpers.d.ts +42 -0
  52. package/dist/src/resolve/Resolvable_helpers.js +19 -0
  53. package/dist/src/resolve/Resolvable_helpers.js.map +1 -0
  54. package/dist/src/resolve/operationTypemap.d.ts +21 -0
  55. package/dist/src/resolve/operationTypemap.js +138 -0
  56. package/dist/src/resolve/operationTypemap.js.map +1 -0
  57. package/dist/src/resolve/types/Enum.d.ts +21 -0
  58. package/dist/src/resolve/types/Enum.js +61 -0
  59. package/dist/src/resolve/types/Enum.js.map +1 -0
  60. package/dist/src/resolve/types/Model.Indexed.d.ts +12 -0
  61. package/dist/src/resolve/types/Model.Indexed.js +69 -0
  62. package/dist/src/resolve/types/Model.Indexed.js.map +1 -0
  63. package/dist/src/resolve/types/Model.Shaped.d.ts +17 -0
  64. package/dist/src/resolve/types/Model.Shaped.js +210 -0
  65. package/dist/src/resolve/types/Model.Shaped.js.map +1 -0
  66. package/dist/src/resolve/types/Scalar.d.ts +9 -0
  67. package/dist/src/resolve/types/Scalar.js +109 -0
  68. package/dist/src/resolve/types/Scalar.js.map +1 -0
  69. package/dist/src/resolve/types/Simple.d.ts +11 -0
  70. package/dist/src/resolve/types/Simple.js +49 -0
  71. package/dist/src/resolve/types/Simple.js.map +1 -0
  72. package/dist/src/resolve/types/Tuple.d.ts +9 -0
  73. package/dist/src/resolve/types/Tuple.js +38 -0
  74. package/dist/src/resolve/types/Tuple.js.map +1 -0
  75. package/dist/src/resolve/types/Union.d.ts +9 -0
  76. package/dist/src/resolve/types/Union.js +36 -0
  77. package/dist/src/resolve/types/Union.js.map +1 -0
  78. package/eslint.config.js +12 -4
  79. package/package.json +2 -2
  80. package/src/emit_routedTypemap.ts +128 -0
  81. package/src/emit_routes.ts +108 -61
  82. package/src/emit_types.ts +137 -92
  83. package/src/emitter.ts +19 -107
  84. package/src/helpers/appendableString.ts +52 -0
  85. package/src/helpers/arrays.ts +21 -0
  86. package/src/{helper_autogenerateWarning.ts → helpers/autogenerateWarning.ts} +0 -1
  87. package/src/helpers/buildTypeMap.ts +72 -0
  88. package/src/helpers/diagnostics.ts +19 -0
  89. package/src/helpers/getImports.ts +9 -0
  90. package/src/helpers/namespaces.ts +18 -0
  91. package/src/helpers/visibilityHelperFile.ts +63 -0
  92. package/src/lib.ts +25 -4
  93. package/src/parseOptions.ts +26 -0
  94. package/src/resolve/Resolvable.ts +267 -0
  95. package/src/resolve/Resolvable_helpers.ts +65 -0
  96. package/src/resolve/operationTypemap.ts +212 -0
  97. package/src/resolve/types/Enum.ts +92 -0
  98. package/src/resolve/types/Model.Indexed.ts +113 -0
  99. package/src/resolve/types/Model.Shaped.ts +291 -0
  100. package/src/resolve/types/Scalar.ts +140 -0
  101. package/src/resolve/types/Simple.ts +88 -0
  102. package/src/resolve/types/Tuple.ts +56 -0
  103. package/src/resolve/types/Union.ts +52 -0
  104. package/test/helpers/integrationTest-novis.tsp +51 -0
  105. package/test/helpers/integrationTest.tsp +53 -0
  106. package/test/helpers/largeModel.tsp +40 -0
  107. package/test/{runner.ts → helpers/runner.ts} +1 -1
  108. package/test/helpers/ts.ts +11 -0
  109. package/test/helpers/wrapper.ts +144 -0
  110. package/test/routes/routes.target.ts +35 -0
  111. package/test/routes/routes.test.ts +22 -0
  112. package/test/typeguards/combined.test.ts +78 -0
  113. package/test/typeguards/enum.test.ts +10 -0
  114. package/test/typeguards/model.indexed.test.ts +68 -0
  115. package/test/typeguards/model.shaped.test.ts +38 -0
  116. package/test/typeguards/scalar.test.ts +62 -0
  117. package/test/typeguards/simple.test.ts +35 -0
  118. package/test/typeguards/tuple.test.ts +34 -0
  119. package/test/typeguards/union.test.ts +29 -0
  120. package/test/typemap/typemap-novis.target.ts +38 -0
  121. package/test/typemap/typemap.target.ts +39 -0
  122. package/test/typemap/typemap.test.ts +48 -0
  123. package/test/types/combined.test.ts +71 -0
  124. package/test/types/enum.test.ts +57 -0
  125. package/test/types/model.indexed.test.ts +46 -0
  126. package/test/types/model.shaped.test.ts +23 -0
  127. package/test/types/scalar.test.ts +53 -0
  128. package/test/types/simple.test.ts +20 -0
  129. package/test/types/tuple.test.ts +29 -0
  130. package/test/types/union.test.ts +20 -0
  131. package/tsconfig.json +1 -0
  132. package/dist/src/emit_mapped_types.d.ts +0 -2
  133. package/dist/src/emit_mapped_types.js +0 -124
  134. package/dist/src/emit_mapped_types.js.map +0 -1
  135. package/dist/src/emit_types_resolve.d.ts +0 -22
  136. package/dist/src/emit_types_resolve.js +0 -217
  137. package/dist/src/emit_types_resolve.js.map +0 -1
  138. package/dist/src/emit_types_typeguards.d.ts +0 -17
  139. package/dist/src/emit_types_typeguards.js +0 -121
  140. package/dist/src/emit_types_typeguards.js.map +0 -1
  141. package/dist/src/helper_autogenerateWarning.js.map +0 -1
  142. package/src/emit_mapped_types.ts +0 -155
  143. package/src/emit_types_resolve.ts +0 -280
  144. package/src/emit_types_typeguards.ts +0 -178
  145. package/test/main.test.ts +0 -83
  146. package/test/out/.gitkeep +0 -0
  147. package/test/targets/enum.routed-types.ts +0 -59
  148. package/test/targets/enum.routes.ts +0 -29
  149. package/test/targets/enum.target.ts +0 -39
  150. package/test/targets/enum.tsp +0 -36
  151. package/test/targets/pr8.routed-types.ts +0 -131
  152. package/test/targets/pr8.routes.ts +0 -30
  153. package/test/targets/pr8.target.ts +0 -97
  154. package/test/targets/pr8.tsp +0 -62
  155. package/test/targets/simple-routes.routed-types.ts +0 -64
  156. package/test/targets/simple-routes.routes.ts +0 -29
  157. package/test/targets/simple-routes.target.ts +0 -21
  158. package/test/targets/simple-routes.tsp +0 -23
  159. package/test/targets/union.routed-types.ts +0 -59
  160. package/test/targets/union.routes.ts +0 -23
  161. package/test/targets/union.target.ts +0 -59
  162. package/test/targets/union.tsp +0 -38
  163. package/test/targets/visibility.routed-types.ts +0 -81
  164. package/test/targets/visibility.routes.ts +0 -38
  165. package/test/targets/visibility.target.ts +0 -36
  166. package/test/targets/visibility.tsp +0 -49
@@ -1,59 +0,0 @@
1
- /* eslint-disable */
2
-
3
- /*
4
- * This file is automatically generated by typespec-typescript-emitter.
5
- *
6
- * You should not change or manipulate this file, as it will be overwritten.
7
- * Instead, change the underlying spec.
8
- */
9
-
10
- export type types_test = {
11
- ["/test-simple"]: {
12
- ["GET"]: {
13
- request: null;
14
- response: {
15
- status: 200;
16
- body: {
17
- status: 0 | 1;
18
- status_shifted: 1 | 2;
19
- status_text: "Status 1" | "Status 2";
20
- }[];
21
- };
22
- };
23
- ["POST"]: {
24
- request: {
25
- status: 0 | 1;
26
- status_shifted: 1 | 2;
27
- status_text: "Status 1" | "Status 2";
28
- };
29
- response: {
30
- status: 200;
31
- body: {
32
- /** The status code. */
33
- statusCode: 200;
34
- };
35
- };
36
- };
37
- };
38
- ["/test-simple/{id}"]: {
39
- ["GET"]: {
40
- request: null;
41
- response:
42
- | {
43
- status: 200;
44
- body: {
45
- status: 0 | 1;
46
- status_shifted: 1 | 2;
47
- status_text: "Status 1" | "Status 2";
48
- };
49
- }
50
- | {
51
- status: 404;
52
- body: {
53
- /** The status code. */
54
- statusCode: 404;
55
- };
56
- };
57
- };
58
- };
59
- };
@@ -1,29 +0,0 @@
1
- /* eslint-disable */
2
-
3
- /*
4
- * This file is automatically generated by typespec-typescript-emitter.
5
- *
6
- * You should not change or manipulate this file, as it will be overwritten.
7
- * Instead, change the underlying spec.
8
- */
9
-
10
- export const routes_test = {
11
- getAll: {
12
- method: "GET",
13
- path: "/test-simple",
14
- getUrl: (): string => `/test-simple`,
15
- auth: [null],
16
- },
17
- add: {
18
- method: "POST",
19
- path: "/test-simple",
20
- getUrl: (): string => `/test-simple`,
21
- auth: [null],
22
- },
23
- getOne: {
24
- method: "GET",
25
- path: "/test-simple/{id}",
26
- getUrl: (params: { id: string }): string => `/test-simple/${params.id}`,
27
- auth: [null],
28
- },
29
- } as const;
@@ -1,39 +0,0 @@
1
- /* eslint-disable */
2
-
3
- /*
4
- * This file is automatically generated by typespec-typescript-emitter.
5
- *
6
- * You should not change or manipulate this file, as it will be overwritten.
7
- * Instead, change the underlying spec.
8
- */
9
-
10
- export enum Status {
11
- STATUS_1,
12
- STATUS_2,
13
- }
14
-
15
- export enum StatusShifted {
16
- STATUS_1 = 1,
17
- STATUS_2 = 2,
18
- }
19
-
20
- export enum StatusText {
21
- STATUS_1 = "Status 1",
22
- STATUS_2 = "Status 2",
23
- }
24
-
25
- export interface TestEnumModel {
26
- status: Status;
27
- status_shifted: StatusShifted;
28
- status_text: StatusText;
29
- }
30
- export function isTestEnumModel(arg: any): arg is TestEnumModel {
31
- return (
32
- arg["status"] !== undefined &&
33
- true &&
34
- arg["status_shifted"] !== undefined &&
35
- true &&
36
- arg["status_text"] !== undefined &&
37
- true
38
- );
39
- }
@@ -1,36 +0,0 @@
1
- import "@typespec/http";
2
- using TypeSpec.Http;
3
-
4
- @route("/test-simple")
5
- namespace test {
6
- enum Status {
7
- STATUS_1,
8
- STATUS_2
9
- }
10
- enum StatusShifted {
11
- STATUS_1: 1,
12
- STATUS_2: 2
13
- }
14
- enum StatusText {
15
- STATUS_1: "Status 1",
16
- STATUS_2: "Status 2"
17
- }
18
-
19
- model TestEnumModel {
20
- status: Status,
21
- status_shifted: StatusShifted,
22
- status_text: StatusText
23
- }
24
-
25
- @get
26
- op getAll(): {@body body: TestEnumModel[]};
27
-
28
- @post
29
- op add(@body body: TestEnumModel): OkResponse;
30
-
31
- @get
32
- @route("{id}")
33
- op getOne(
34
- @path id: int32
35
- ): {@body body: TestEnumModel} | NotFoundResponse;
36
- }
@@ -1,131 +0,0 @@
1
- /* eslint-disable */
2
-
3
- /*
4
- * This file is automatically generated by typespec-typescript-emitter.
5
- *
6
- * You should not change or manipulate this file, as it will be overwritten.
7
- * Instead, change the underlying spec.
8
- */
9
-
10
- export type types_test = {
11
- ["/test-simple/widgets"]: {
12
- ["GET"]: {
13
- request: null;
14
- response:
15
- | {
16
- status: 200;
17
- body: {
18
- id: string;
19
- status: "active" | "inactive";
20
- details:
21
- | {
22
- type: "small";
23
- weight: number;
24
- color: "red" | "blue";
25
- }
26
- | {
27
- type: "large";
28
- size: string;
29
- capacity: number;
30
- };
31
- tags?: {
32
- name: string;
33
- value: string;
34
- }[];
35
- }[];
36
- }
37
- | {
38
- status: 200;
39
- body: {
40
- code: number;
41
- message: string;
42
- };
43
- };
44
- };
45
- ["POST"]: {
46
- request: {
47
- status: "active" | "inactive";
48
- details:
49
- | {
50
- type: "small";
51
- weight: number;
52
- color: "red" | "blue";
53
- }
54
- | {
55
- type: "large";
56
- size: string;
57
- capacity: number;
58
- };
59
- tags?: {
60
- name: string;
61
- value: string;
62
- }[];
63
- };
64
- response:
65
- | {
66
- status: 200;
67
- body: {
68
- id: string;
69
- status: "active" | "inactive";
70
- details:
71
- | {
72
- type: "small";
73
- weight: number;
74
- color: "red" | "blue";
75
- }
76
- | {
77
- type: "large";
78
- size: string;
79
- capacity: number;
80
- };
81
- tags?: {
82
- name: string;
83
- value: string;
84
- }[];
85
- };
86
- }
87
- | {
88
- status: 200;
89
- body: {
90
- code: number;
91
- message: string;
92
- };
93
- };
94
- };
95
- };
96
- ["/test-simple/widgets/{id}"]: {
97
- ["GET"]: {
98
- request: null;
99
- response:
100
- | {
101
- status: 200;
102
- body: {
103
- id: string;
104
- status: "active" | "inactive";
105
- details:
106
- | {
107
- type: "small";
108
- weight: number;
109
- color: "red" | "blue";
110
- }
111
- | {
112
- type: "large";
113
- size: string;
114
- capacity: number;
115
- };
116
- tags?: {
117
- name: string;
118
- value: string;
119
- }[];
120
- };
121
- }
122
- | {
123
- status: 200;
124
- body: {
125
- code: number;
126
- message: string;
127
- };
128
- };
129
- };
130
- };
131
- };
@@ -1,30 +0,0 @@
1
- /* eslint-disable */
2
-
3
- /*
4
- * This file is automatically generated by typespec-typescript-emitter.
5
- *
6
- * You should not change or manipulate this file, as it will be overwritten.
7
- * Instead, change the underlying spec.
8
- */
9
-
10
- export const routes_test = {
11
- list: {
12
- method: "GET",
13
- path: "/test-simple/widgets",
14
- getUrl: (): string => `/test-simple/widgets`,
15
- auth: [null],
16
- },
17
- read: {
18
- method: "GET",
19
- path: "/test-simple/widgets/{id}",
20
- getUrl: (params: { id: string }): string =>
21
- `/test-simple/widgets/${params.id}`,
22
- auth: [null],
23
- },
24
- create: {
25
- method: "POST",
26
- path: "/test-simple/widgets",
27
- getUrl: (): string => `/test-simple/widgets`,
28
- auth: [null],
29
- },
30
- } as const;
@@ -1,97 +0,0 @@
1
- /* eslint-disable */
2
-
3
- /*
4
- * This file is automatically generated by typespec-typescript-emitter.
5
- *
6
- * You should not change or manipulate this file, as it will be overwritten.
7
- * Instead, change the underlying spec.
8
- */
9
-
10
- export enum WidgetSize {
11
- SMALL = "small",
12
- LARGE = "large",
13
- }
14
-
15
- export enum WidgetStatus {
16
- ACTIVE = "active",
17
- INACTIVE = "inactive",
18
- }
19
-
20
- export type WidgetDetails = SmallWidget | LargeWidget;
21
-
22
- export interface Tag {
23
- name: string;
24
- value: string;
25
- }
26
- export function isTag(arg: any): arg is Tag {
27
- return (
28
- arg["name"] !== undefined &&
29
- typeof arg["name"] === "string" &&
30
- arg["value"] !== undefined &&
31
- typeof arg["value"] === "string"
32
- );
33
- }
34
-
35
- export interface SmallWidget {
36
- type: WidgetSize.SMALL;
37
- weight: number;
38
- color: "red" | "blue";
39
- }
40
- export function isSmallWidget(arg: any): arg is SmallWidget {
41
- return (
42
- arg["type"] !== undefined &&
43
- true &&
44
- arg["weight"] !== undefined &&
45
- typeof arg["weight"] === "number" &&
46
- arg["color"] !== undefined &&
47
- (typeof arg["color"] === "string" || typeof arg["color"] === "string")
48
- );
49
- }
50
-
51
- export interface LargeWidget {
52
- type: WidgetSize.LARGE;
53
- size: string;
54
- capacity: number;
55
- }
56
- export function isLargeWidget(arg: any): arg is LargeWidget {
57
- return (
58
- arg["type"] !== undefined &&
59
- true &&
60
- arg["size"] !== undefined &&
61
- typeof arg["size"] === "string" &&
62
- arg["capacity"] !== undefined &&
63
- typeof arg["capacity"] === "number"
64
- );
65
- }
66
-
67
- export interface Widget {
68
- id: string;
69
- status: WidgetStatus;
70
- details: WidgetDetails;
71
- tags?: Tag[];
72
- }
73
- export function isWidget(arg: any): arg is Widget {
74
- return (
75
- (arg["id"] !== undefined &&
76
- typeof arg["id"] === "string" &&
77
- arg["status"] !== undefined &&
78
- true &&
79
- arg["details"] !== undefined &&
80
- (isSmallWidget(arg["details"]) || isLargeWidget(arg["details"])) &&
81
- arg["tags"] === undefined) ||
82
- (Array.isArray(arg["tags"]) && arg["tags"].every((v) => isTag(v)))
83
- );
84
- }
85
-
86
- export interface Error {
87
- code: number;
88
- message: string;
89
- }
90
- export function isError(arg: any): arg is Error {
91
- return (
92
- arg["code"] !== undefined &&
93
- typeof arg["code"] === "number" &&
94
- arg["message"] !== undefined &&
95
- typeof arg["message"] === "string"
96
- );
97
- }
@@ -1,62 +0,0 @@
1
- import "@typespec/http";
2
- using TypeSpec.Http;
3
-
4
- @route("/test-simple")
5
- namespace test {
6
- enum WidgetSize {
7
- SMALL: "small",
8
- LARGE: "large",
9
- }
10
-
11
- enum WidgetStatus {
12
- ACTIVE: "active",
13
- INACTIVE: "inactive",
14
- }
15
-
16
- model Tag {
17
- name: string;
18
- value: string;
19
- }
20
-
21
- model SmallWidget {
22
- type: WidgetSize.SMALL;
23
- weight: int32;
24
- color: "red" | "blue";
25
- }
26
-
27
- model LargeWidget {
28
- type: WidgetSize.LARGE;
29
- size: string;
30
- capacity: int32;
31
- }
32
-
33
- union WidgetDetails {
34
- small: SmallWidget,
35
- large: LargeWidget,
36
- }
37
-
38
- model Widget {
39
- @visibility(Lifecycle.Read)
40
- id: string;
41
-
42
- status: WidgetStatus;
43
-
44
- details: WidgetDetails;
45
-
46
- tags?: Tag[];
47
- }
48
-
49
- @error
50
- model Error {
51
- code: int32;
52
- message: string;
53
- }
54
-
55
- @route("/widgets")
56
- @tag("Widgets")
57
- interface Widgets {
58
- @get list(): Widget[] | Error;
59
- @get read(@path id: string): Widget | Error;
60
- @post create(@body widget: Widget): Widget | Error;
61
- }
62
- }
@@ -1,64 +0,0 @@
1
- /* eslint-disable */
2
-
3
- /*
4
- * This file is automatically generated by typespec-typescript-emitter.
5
- *
6
- * You should not change or manipulate this file, as it will be overwritten.
7
- * Instead, change the underlying spec.
8
- */
9
-
10
- export type types_test = {
11
- ["/test-simple"]: {
12
- ["GET"]: {
13
- request: null;
14
- response:
15
- | {
16
- status: 200;
17
- body: {
18
- id: number;
19
- name: string;
20
- }[];
21
- }
22
- | { status: 418; body: "Me teapot" };
23
- };
24
- ["POST"]: {
25
- request: {
26
- name: string;
27
- };
28
- response: {
29
- status: 200;
30
- body: {
31
- /** The status code. */
32
- statusCode: 200;
33
- };
34
- };
35
- };
36
- };
37
- ["/test-simple/{id}"]: {
38
- ["GET"]: {
39
- request: null;
40
- response:
41
- | {
42
- status: 200;
43
- body: {
44
- id: number;
45
- name: string;
46
- };
47
- }
48
- | {
49
- status: 404;
50
- body: {
51
- /** The status code. */
52
- statusCode: 404;
53
- };
54
- }
55
- | {
56
- status: 418;
57
- body: {
58
- status: 418;
59
- };
60
- }
61
- | { status: 419; body: {} };
62
- };
63
- };
64
- };
@@ -1,29 +0,0 @@
1
- /* eslint-disable */
2
-
3
- /*
4
- * This file is automatically generated by typespec-typescript-emitter.
5
- *
6
- * You should not change or manipulate this file, as it will be overwritten.
7
- * Instead, change the underlying spec.
8
- */
9
-
10
- export const routes_test = {
11
- getAll: {
12
- method: "GET",
13
- path: "/test-simple",
14
- getUrl: (): string => `/test-simple`,
15
- auth: [null],
16
- },
17
- add: {
18
- method: "POST",
19
- path: "/test-simple",
20
- getUrl: (): string => `/test-simple`,
21
- auth: [null],
22
- },
23
- getOne: {
24
- method: "GET",
25
- path: "/test-simple/{id}",
26
- getUrl: (params: { id: string }): string => `/test-simple/${params.id}`,
27
- auth: [null],
28
- },
29
- } as const;
@@ -1,21 +0,0 @@
1
- /* eslint-disable */
2
-
3
- /*
4
- * This file is automatically generated by typespec-typescript-emitter.
5
- *
6
- * You should not change or manipulate this file, as it will be overwritten.
7
- * Instead, change the underlying spec.
8
- */
9
-
10
- export interface TestSimpleA {
11
- id: number;
12
- name: string;
13
- }
14
- export function isTestSimpleA(arg: any): arg is TestSimpleA {
15
- return (
16
- arg["id"] !== undefined &&
17
- typeof arg["id"] === "number" &&
18
- arg["name"] !== undefined &&
19
- typeof arg["name"] === "string"
20
- );
21
- }
@@ -1,23 +0,0 @@
1
- import "@typespec/http";
2
- using TypeSpec.Http;
3
-
4
- @route("/test-simple")
5
- namespace test {
6
- model TestSimpleA {
7
- @visibility(Lifecycle.Read)
8
- id: int32,
9
- name: string
10
- }
11
-
12
- @get
13
- op getAll(): {@body body: TestSimpleA[]} | {@statusCode status: 418, @body body: "Me teapot"};
14
-
15
- @post
16
- op add(@body body: TestSimpleA): OkResponse;
17
-
18
- @get
19
- @route("{id}")
20
- op getOne(
21
- @path id: int32
22
- ): {@body body: TestSimpleA} | NotFoundResponse | {@statusCode status: 418} | {@statusCode status: 419, @body body: {}};
23
- }
@@ -1,59 +0,0 @@
1
- /* eslint-disable */
2
-
3
- /*
4
- * This file is automatically generated by typespec-typescript-emitter.
5
- *
6
- * You should not change or manipulate this file, as it will be overwritten.
7
- * Instead, change the underlying spec.
8
- */
9
-
10
- export type types_test = {
11
- ["/test-simple"]: {
12
- ["GET"]: {
13
- request: null;
14
- response:
15
- | {
16
- status: 200;
17
- body: (
18
- | {
19
- a: boolean;
20
- b: boolean;
21
- }
22
- | number
23
- )[];
24
- }
25
- | { status: 418; body: "Me teapot" };
26
- };
27
- ["POST"]: {
28
- request:
29
- | {
30
- a: boolean;
31
- b: boolean;
32
- }
33
- | number;
34
- response: {
35
- status: 200;
36
- body: {
37
- a:
38
- | number
39
- | {
40
- a: boolean;
41
- b: boolean;
42
- }
43
- | number;
44
- b: boolean | string;
45
- c:
46
- | {
47
- a: boolean;
48
- b: boolean;
49
- }
50
- | number
51
- | {
52
- b: boolean;
53
- }
54
- | number;
55
- };
56
- };
57
- };
58
- };
59
- };