@typespec/http 0.44.0-dev.4 → 0.44.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/lib/auth.tsp +5 -0
- package/lib/http-decorators.tsp +2 -1
- package/lib/http.tsp +37 -0
- package/package.json +1 -1
package/lib/auth.tsp
CHANGED
|
@@ -61,6 +61,7 @@ enum ApiKeyLocation {
|
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
63
|
* An API key is a token that a client provides when making API calls. The key can be sent in the query string:
|
|
64
|
+
*
|
|
64
65
|
* ```
|
|
65
66
|
* GET /something?api_key=abcdef12345
|
|
66
67
|
* ```
|
|
@@ -78,6 +79,9 @@ enum ApiKeyLocation {
|
|
|
78
79
|
* GET /something HTTP/1.1
|
|
79
80
|
* Cookie: X-API-KEY=abcdef12345
|
|
80
81
|
* ```
|
|
82
|
+
*
|
|
83
|
+
* @template TLocation The location of the API key
|
|
84
|
+
* @template TName The name of the API key
|
|
81
85
|
*/
|
|
82
86
|
model ApiKeyAuth<TLocation extends ApiKeyLocation, TName extends string> {
|
|
83
87
|
@doc("API key authentication")
|
|
@@ -95,6 +99,7 @@ model ApiKeyAuth<TLocation extends ApiKeyLocation, TName extends string> {
|
|
|
95
99
|
* OAuth relies on authentication scenarios called flows, which allow the resource owner (user) to share the protected content from the resource server without sharing their credentials.
|
|
96
100
|
* For that purpose, an OAuth 2.0 server issues access tokens that the client applications can use to access protected resources on behalf of the resource owner.
|
|
97
101
|
* For more information about OAuth 2.0, see oauth.net and RFC 6749.
|
|
102
|
+
* @template TFlows The list of supported OAuth2 flows
|
|
98
103
|
*/
|
|
99
104
|
model OAuth2Auth<TFlows extends OAuth2Flow[]> {
|
|
100
105
|
@doc("OAuth2 authentication")
|
package/lib/http-decorators.tsp
CHANGED
|
@@ -202,6 +202,7 @@ extern dec useAuth(target: Namespace, auth: object | Union | object[]);
|
|
|
202
202
|
|
|
203
203
|
/**
|
|
204
204
|
* Specify if inapplicable metadata should be included in the payload for the given entity.
|
|
205
|
+
* @param value If true, inapplicable metadata will be included in the payload.
|
|
205
206
|
*/
|
|
206
207
|
extern dec includeInapplicableMetadataInPayload(target: unknown, value: boolean);
|
|
207
208
|
|
|
@@ -215,7 +216,7 @@ extern dec includeInapplicableMetadataInPayload(target: unknown, value: boolean)
|
|
|
215
216
|
* `@route` can only be applied to operations, namespaces, and interfaces.
|
|
216
217
|
*
|
|
217
218
|
* @param path Relative route path. Cannot include query parameters.
|
|
218
|
-
* @param
|
|
219
|
+
* @param options Set of parameters used to configure the route. Supports `{shared: true}` which indicates that the route may be shared by several operations.
|
|
219
220
|
*
|
|
220
221
|
* @example
|
|
221
222
|
*
|
package/lib/http.tsp
CHANGED
|
@@ -30,6 +30,9 @@ model Body<T> {
|
|
|
30
30
|
body: T;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* The Location header contains the URL where the status of the long running operation can be checked.
|
|
35
|
+
*/
|
|
33
36
|
model LocationHeader {
|
|
34
37
|
@doc("The Location header contains the URL where the status of the long running operation can be checked.")
|
|
35
38
|
@header
|
|
@@ -40,18 +43,52 @@ model LocationHeader {
|
|
|
40
43
|
// to update the default descriptions for these status codes. This ensures
|
|
41
44
|
// that we get consistent emit between different ways to spell the same
|
|
42
45
|
// responses in TypeSpec.
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The request has succeeded.
|
|
49
|
+
*/
|
|
43
50
|
model OkResponse is Response<200>;
|
|
51
|
+
/**
|
|
52
|
+
* The request has succeeded and a new resource has been created as a result.
|
|
53
|
+
*/
|
|
44
54
|
model CreatedResponse is Response<201>;
|
|
55
|
+
/**
|
|
56
|
+
* The request has been accepted for processing, but processing has not yet completed.
|
|
57
|
+
*/
|
|
45
58
|
model AcceptedResponse is Response<202>;
|
|
59
|
+
/**
|
|
60
|
+
* There is no content to send for this request, but the headers may be useful.
|
|
61
|
+
*/
|
|
46
62
|
model NoContentResponse is Response<204>;
|
|
63
|
+
/**
|
|
64
|
+
* The URL of the requested resource has been changed permanently. The new URL is given in the response.
|
|
65
|
+
*/
|
|
47
66
|
model MovedResponse is Response<301> {
|
|
48
67
|
...LocationHeader;
|
|
49
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* The client has made a conditional request and the resource has not been modified.
|
|
71
|
+
*/
|
|
50
72
|
model NotModifiedResponse is Response<304>;
|
|
73
|
+
/**
|
|
74
|
+
* The server could not understand the request due to invalid syntax.
|
|
75
|
+
*/
|
|
51
76
|
model BadRequestResponse is Response<400>;
|
|
77
|
+
/**
|
|
78
|
+
* Access is unauthorized.
|
|
79
|
+
*/
|
|
52
80
|
model UnauthorizedResponse is Response<401>;
|
|
81
|
+
/**
|
|
82
|
+
* Access is forbidden.
|
|
83
|
+
*/
|
|
53
84
|
model ForbiddenResponse is Response<403>;
|
|
85
|
+
/**
|
|
86
|
+
* The server cannot find the requested resource.
|
|
87
|
+
*/
|
|
54
88
|
model NotFoundResponse is Response<404>;
|
|
89
|
+
/**
|
|
90
|
+
* The request conflicts with the current state of the server.
|
|
91
|
+
*/
|
|
55
92
|
model ConflictResponse is Response<409>;
|
|
56
93
|
|
|
57
94
|
/**
|