@typespec/compiler 0.65.0-dev.4 → 0.65.0-dev.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/manifest.js +2 -2
- package/package.json +1 -1
- package/templates/__snapshots__/rest/.gitignore +9 -0
- package/templates/__snapshots__/rest/main.tsp +40 -0
- package/templates/__snapshots__/rest/package.json +20 -0
- package/templates/__snapshots__/rest/tspconfig.yaml +16 -0
- package/templates/rest/main.tsp +40 -0
- package/templates/scaffolding.json +51 -5
package/dist/manifest.js
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import "@typespec/http";
|
|
2
|
+
|
|
3
|
+
using TypeSpec.Http;
|
|
4
|
+
@service({
|
|
5
|
+
title: "Widget Service",
|
|
6
|
+
})
|
|
7
|
+
namespace DemoService;
|
|
8
|
+
|
|
9
|
+
model Widget {
|
|
10
|
+
@visibility("read", "update")
|
|
11
|
+
@path
|
|
12
|
+
id: string;
|
|
13
|
+
|
|
14
|
+
weight: int32;
|
|
15
|
+
color: "red" | "blue";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@error
|
|
19
|
+
model Error {
|
|
20
|
+
code: int32;
|
|
21
|
+
message: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@route("/widgets")
|
|
25
|
+
@tag("Widgets")
|
|
26
|
+
interface Widgets {
|
|
27
|
+
/** List widgets */
|
|
28
|
+
@get list(): Widget[] | Error;
|
|
29
|
+
/** Read widgets */
|
|
30
|
+
@get read(@path id: string): Widget | Error;
|
|
31
|
+
/** Create a widget */
|
|
32
|
+
@post create(...Widget): Widget | Error;
|
|
33
|
+
/** Update a widget */
|
|
34
|
+
@patch update(...Widget): Widget | Error;
|
|
35
|
+
/** Delete a widget */
|
|
36
|
+
@delete delete(@path id: string): void | Error;
|
|
37
|
+
|
|
38
|
+
/** Analyze a widget */
|
|
39
|
+
@route("{id}/analyze") @post analyze(@path id: string): string | Error;
|
|
40
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rest",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"peerDependencies": {
|
|
6
|
+
"@typespec/compiler": "latest",
|
|
7
|
+
"@typespec/http": "latest",
|
|
8
|
+
"@typespec/rest": "latest",
|
|
9
|
+
"@typespec/openapi": "latest",
|
|
10
|
+
"@typespec/openapi3": "latest"
|
|
11
|
+
},
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"@typespec/compiler": "latest",
|
|
14
|
+
"@typespec/http": "latest",
|
|
15
|
+
"@typespec/rest": "latest",
|
|
16
|
+
"@typespec/openapi": "latest",
|
|
17
|
+
"@typespec/openapi3": "latest"
|
|
18
|
+
},
|
|
19
|
+
"private": true
|
|
20
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# extends: ../tspconfig.yaml # Extend another config file
|
|
2
|
+
# emit: # Emitter name
|
|
3
|
+
# - "<emitter-name"
|
|
4
|
+
# options: # Emitter options
|
|
5
|
+
# <emitter-name>:
|
|
6
|
+
# "<option-name>": "<option-value>"
|
|
7
|
+
# environment-variables: # Environment variables which can be used to interpolate emitter options
|
|
8
|
+
# <variable-name>:
|
|
9
|
+
# default: "<variable-default>"
|
|
10
|
+
# parameters: # Parameters which can be used to interpolate emitter options
|
|
11
|
+
# <param-name>:
|
|
12
|
+
# default: "<param-default>"
|
|
13
|
+
# trace: # Trace areas to enable tracing
|
|
14
|
+
# - "<trace-name>"
|
|
15
|
+
# warn-as-error: true # Treat warnings as errors
|
|
16
|
+
# output-dir: "{project-root}/_generated" # Configure the base output directory for all emitters
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import "@typespec/http";
|
|
2
|
+
|
|
3
|
+
using TypeSpec.Http;
|
|
4
|
+
@service({
|
|
5
|
+
title: "Widget Service",
|
|
6
|
+
})
|
|
7
|
+
namespace DemoService;
|
|
8
|
+
|
|
9
|
+
model Widget {
|
|
10
|
+
@visibility("read", "update")
|
|
11
|
+
@path
|
|
12
|
+
id: string;
|
|
13
|
+
|
|
14
|
+
weight: int32;
|
|
15
|
+
color: "red" | "blue";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@error
|
|
19
|
+
model Error {
|
|
20
|
+
code: int32;
|
|
21
|
+
message: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@route("/widgets")
|
|
25
|
+
@tag("Widgets")
|
|
26
|
+
interface Widgets {
|
|
27
|
+
/** List widgets */
|
|
28
|
+
@get list(): Widget[] | Error;
|
|
29
|
+
/** Read widgets */
|
|
30
|
+
@get read(@path id: string): Widget | Error;
|
|
31
|
+
/** Create a widget */
|
|
32
|
+
@post create(...Widget): Widget | Error;
|
|
33
|
+
/** Update a widget */
|
|
34
|
+
@patch update(...Widget): Widget | Error;
|
|
35
|
+
/** Delete a widget */
|
|
36
|
+
@delete delete(@path id: string): void | Error;
|
|
37
|
+
|
|
38
|
+
/** Analyze a widget */
|
|
39
|
+
@route("{id}/analyze") @post analyze(@path id: string): string | Error;
|
|
40
|
+
}
|
|
@@ -12,13 +12,59 @@
|
|
|
12
12
|
"libraries": [
|
|
13
13
|
"@typespec/http",
|
|
14
14
|
"@typespec/rest",
|
|
15
|
+
"@typespec/openapi",
|
|
15
16
|
"@typespec/openapi3"
|
|
16
17
|
],
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
"emitters": {
|
|
19
|
+
"@typespec/openapi3": {
|
|
20
|
+
"selected": true,
|
|
21
|
+
"options": {
|
|
22
|
+
"emitter-output-dir": "{output-dir}/schema"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"@typespec/http-client-csharp": {
|
|
26
|
+
"description": "CSharp Client emitter",
|
|
27
|
+
"options": {
|
|
28
|
+
"emitter-output-dir": "{output-dir}/clients/csharp"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"@typespec/http-client-java": {
|
|
32
|
+
"description": "Java Client emitter",
|
|
33
|
+
"options": {
|
|
34
|
+
"emitter-output-dir": "{output-dir}/clients/java"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"@typespec/http-client-js": {
|
|
38
|
+
"description": "JavaScript Client emitter",
|
|
39
|
+
"options": {
|
|
40
|
+
"emitter-output-dir": "{output-dir}/clients/js"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"@typespec/http-client-python": {
|
|
44
|
+
"description": "Python Client emitter",
|
|
45
|
+
"options": {
|
|
46
|
+
"emitter-output-dir": "{output-dir}/clients/python"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"@typespec/http-server-csharp": {
|
|
50
|
+
"description": "CSharp server stubs",
|
|
51
|
+
"options": {
|
|
52
|
+
"emitter-output-dir": "{output-dir}/server"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"@typespec/http-server-js": {
|
|
56
|
+
"description": "Javascript server stubs",
|
|
57
|
+
"options": {
|
|
58
|
+
"emitter-output-dir": "{output-dir}/server"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"files": [
|
|
63
|
+
{
|
|
64
|
+
"path": "rest/main.tsp",
|
|
65
|
+
"destination": "main.tsp"
|
|
66
|
+
}
|
|
67
|
+
]
|
|
22
68
|
},
|
|
23
69
|
"library-ts": {
|
|
24
70
|
"title": "TypeSpec Library (With TypeScript)",
|