@typespec/http 0.57.0-dev.2 → 0.57.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/README.md
CHANGED
|
@@ -458,8 +458,8 @@ namespace PetStore;
|
|
|
458
458
|
|
|
459
459
|
```typespec
|
|
460
460
|
@server("https://{region}.foo.com", "Regional endpoint", {
|
|
461
|
-
@doc("Region name")
|
|
462
|
-
region?: string = "westus",
|
|
461
|
+
@doc("Region name")
|
|
462
|
+
region?: string = "westus",
|
|
463
463
|
})
|
|
464
464
|
```
|
|
465
465
|
|
|
@@ -509,8 +509,13 @@ None
|
|
|
509
509
|
##### Examples
|
|
510
510
|
|
|
511
511
|
```typespec
|
|
512
|
-
op read(): {
|
|
513
|
-
|
|
512
|
+
op read(): {
|
|
513
|
+
@statusCode _: 200;
|
|
514
|
+
@body pet: Pet;
|
|
515
|
+
};
|
|
516
|
+
op create(): {
|
|
517
|
+
@statusCode _: 201 | 202;
|
|
518
|
+
};
|
|
514
519
|
```
|
|
515
520
|
|
|
516
521
|
#### `@useAuth`
|
|
@@ -4,8 +4,13 @@ import type { DecoratorContext, Interface, ModelProperty, Namespace, Operation,
|
|
|
4
4
|
*
|
|
5
5
|
* @example
|
|
6
6
|
* ```typespec
|
|
7
|
-
* op read(): {
|
|
8
|
-
*
|
|
7
|
+
* op read(): {
|
|
8
|
+
* @statusCode _: 200;
|
|
9
|
+
* @body pet: Pet;
|
|
10
|
+
* };
|
|
11
|
+
* op create(): {
|
|
12
|
+
* @statusCode _: 201 | 202;
|
|
13
|
+
* };
|
|
9
14
|
* ```
|
|
10
15
|
*/
|
|
11
16
|
export type StatusCodeDecorator = (context: DecoratorContext, target: ModelProperty) => void;
|
|
@@ -154,8 +159,8 @@ export type HeadDecorator = (context: DecoratorContext, target: Operation) => vo
|
|
|
154
159
|
*
|
|
155
160
|
* ```typespec
|
|
156
161
|
* @server("https://{region}.foo.com", "Regional endpoint", {
|
|
157
|
-
*
|
|
158
|
-
*
|
|
162
|
+
* @doc("Region name")
|
|
163
|
+
* region?: string = "westus",
|
|
159
164
|
* })
|
|
160
165
|
* ```
|
|
161
166
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeSpec.Http.d.ts","sourceRoot":"","sources":["../../generated-defs/TypeSpec.Http.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,SAAS,EACT,aAAa,EACb,SAAS,EACT,SAAS,EACT,IAAI,EACL,MAAM,oBAAoB,CAAC;AAE5B
|
|
1
|
+
{"version":3,"file":"TypeSpec.Http.d.ts","sourceRoot":"","sources":["../../generated-defs/TypeSpec.Http.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,SAAS,EACT,aAAa,EACb,SAAS,EACT,SAAS,EACT,IAAI,EACL,MAAM,oBAAoB,CAAC;AAE5B;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;AAE7F;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;AAEvF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,eAAe,GAAG,CAC5B,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,aAAa,EACrB,mBAAmB,CAAC,EAAE,IAAI,KACvB,IAAI,CAAC;AAEV;;;;;;;;;GASG;AACH,MAAM,MAAM,cAAc,GAAG,CAC3B,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,aAAa,EACrB,kBAAkB,CAAC,EAAE,IAAI,KACtB,IAAI,CAAC;AAEV;;;;;;;;;GASG;AACH,MAAM,MAAM,aAAa,GAAG,CAC1B,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,aAAa,EAC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MAAM,MAAM,gBAAgB,GAAG,CAC7B,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,EACzC,IAAI,EAAE,IAAI,KACP,IAAI,CAAC;AAEV;;;;GAIG;AACH,MAAM,MAAM,6CAA6C,GAAG,CAC1D,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,IAAI,EACZ,KAAK,EAAE,OAAO,KACX,IAAI,CAAC;AAEV;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,cAAc,GAAG,CAC3B,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,EACzC,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,IAAI,KACX,IAAI,CAAC;AAEV;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,SAAS,KAAK,IAAI,CAAC"}
|
package/dist/src/types.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export interface HttpAuthBase {
|
|
|
34
34
|
* The client sends HTTP requests with the Authorization header that contains the word Basic word followed by a space and a base64-encoded string username:password.
|
|
35
35
|
* For example, to authorize as demo / p@55w0rd the client would send
|
|
36
36
|
* ```
|
|
37
|
-
*
|
|
37
|
+
* Authorization: Basic ZGVtbzpwQDU1dzByZA==
|
|
38
38
|
* ```
|
|
39
39
|
*/
|
|
40
40
|
export interface BasicAuth extends HttpAuthBase {
|
package/lib/auth.tsp
CHANGED
|
@@ -19,12 +19,12 @@ enum AuthType {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
22
|
+
* Basic authentication is a simple authentication scheme built into the HTTP protocol.
|
|
23
|
+
* The client sends HTTP requests with the Authorization header that contains the word Basic word followed by a space and a base64-encoded string username:password.
|
|
24
|
+
* For example, to authorize as demo / `p@55w0rd` the client would send
|
|
25
|
+
* ```
|
|
26
|
+
* Authorization: Basic ZGVtbzpwQDU1dzByZA==
|
|
27
|
+
* ```
|
|
28
28
|
*/
|
|
29
29
|
@doc("")
|
|
30
30
|
model BasicAuth {
|
|
@@ -40,7 +40,7 @@ model BasicAuth {
|
|
|
40
40
|
* The name “Bearer authentication” can be understood as “give access to the bearer of this token.” The bearer token is a cryptic string, usually generated by the server in response to a login request.
|
|
41
41
|
* The client must send this token in the Authorization header when making requests to protected resources:
|
|
42
42
|
* ```
|
|
43
|
-
*
|
|
43
|
+
* Authorization: Bearer <token>
|
|
44
44
|
* ```
|
|
45
45
|
*/
|
|
46
46
|
@doc("")
|
package/lib/http-decorators.tsp
CHANGED
|
@@ -128,8 +128,13 @@ extern dec bodyIgnore(target: ModelProperty);
|
|
|
128
128
|
* @example
|
|
129
129
|
*
|
|
130
130
|
* ```typespec
|
|
131
|
-
* op read(): {
|
|
132
|
-
*
|
|
131
|
+
* op read(): {
|
|
132
|
+
* @statusCode _: 200;
|
|
133
|
+
* @body pet: Pet;
|
|
134
|
+
* };
|
|
135
|
+
* op create(): {
|
|
136
|
+
* @statusCode _: 201 | 202;
|
|
137
|
+
* };
|
|
133
138
|
* ```
|
|
134
139
|
*/
|
|
135
140
|
extern dec statusCode(target: ModelProperty);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typespec/http",
|
|
3
|
-
"version": "0.57.0-dev.
|
|
3
|
+
"version": "0.57.0-dev.5",
|
|
4
4
|
"author": "Microsoft Corporation",
|
|
5
5
|
"description": "TypeSpec HTTP protocol binding",
|
|
6
6
|
"homepage": "https://github.com/microsoft/typespec",
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
"@types/node": "~18.11.19",
|
|
46
46
|
"@typespec/compiler": "~0.56.0 || >=0.57.0-dev <0.57.0",
|
|
47
47
|
"@typespec/library-linter": "~0.56.0 || >=0.57.0-dev <0.57.0",
|
|
48
|
-
"@vitest/coverage-v8": "^1.
|
|
49
|
-
"@vitest/ui": "^1.
|
|
48
|
+
"@vitest/coverage-v8": "^1.6.0",
|
|
49
|
+
"@vitest/ui": "^1.6.0",
|
|
50
50
|
"c8": "^9.1.0",
|
|
51
|
-
"rimraf": "~5.0.
|
|
51
|
+
"rimraf": "~5.0.7",
|
|
52
52
|
"typescript": "~5.4.5",
|
|
53
|
-
"vitest": "^1.
|
|
53
|
+
"vitest": "^1.6.0",
|
|
54
54
|
"@typespec/tspd": "~0.46.0"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {},
|