@typespec/http 0.43.0-dev.2 → 0.43.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/src/lib.d.ts +17 -2
- package/dist/src/lib.d.ts.map +1 -1
- package/dist/src/lib.js +6 -0
- package/dist/src/lib.js.map +1 -1
- package/dist/src/validate.d.ts.map +1 -1
- package/dist/src/validate.js +20 -1
- package/dist/src/validate.js.map +1 -1
- package/lib/http-decorators.tsp +15 -1
- package/lib/http.tsp +9 -1
- package/package.json +1 -1
package/dist/src/lib.d.ts
CHANGED
|
@@ -50,6 +50,9 @@ declare const httpLib: import("@typespec/compiler").TypeSpecLibrary<{
|
|
|
50
50
|
"shared-boolean": {
|
|
51
51
|
readonly default: "shared parameter must be a boolean.";
|
|
52
52
|
};
|
|
53
|
+
"shared-inconsistency": {
|
|
54
|
+
readonly default: "All shared routes must agree on the value of the shared parameter.";
|
|
55
|
+
};
|
|
53
56
|
"write-visibility-not-supported": {
|
|
54
57
|
readonly default: "@visibility(\"write\") is not supported. Use @visibility(\"update\"), @visibility(\"create\") or @visibility(\"create\", \"update\") as appropriate.";
|
|
55
58
|
};
|
|
@@ -63,7 +66,7 @@ declare const httpLib: import("@typespec/compiler").TypeSpecLibrary<{
|
|
|
63
66
|
readonly default: "A format must be specified for @query when type is an array. e.g. @query({format: \"multi\"})";
|
|
64
67
|
};
|
|
65
68
|
}, Record<string, any>>;
|
|
66
|
-
declare const reportDiagnostic: <C extends "http-verb-duplicate" | "http-verb-wrong-type" | "missing-path-param" | "optional-path-param" | "missing-server-param" | "duplicate-body" | "duplicate-route-decorator" | "operation-param-duplicate-type" | "duplicate-operation" | "status-code-invalid" | "content-type-string" | "duplicate-response" | "content-type-ignored" | "no-routes" | "invalid-type-for-auth" | "shared-boolean" | "write-visibility-not-supported" | "multipart-model" | "header-format-required" | "query-format-required", M extends keyof {
|
|
69
|
+
declare const reportDiagnostic: <C extends "http-verb-duplicate" | "http-verb-wrong-type" | "missing-path-param" | "optional-path-param" | "missing-server-param" | "duplicate-body" | "duplicate-route-decorator" | "operation-param-duplicate-type" | "duplicate-operation" | "status-code-invalid" | "content-type-string" | "duplicate-response" | "content-type-ignored" | "no-routes" | "invalid-type-for-auth" | "shared-boolean" | "shared-inconsistency" | "write-visibility-not-supported" | "multipart-model" | "header-format-required" | "query-format-required", M extends keyof {
|
|
67
70
|
"http-verb-duplicate": {
|
|
68
71
|
readonly default: import("@typespec/compiler").CallableMessage<["entityName"]>;
|
|
69
72
|
};
|
|
@@ -115,6 +118,9 @@ declare const reportDiagnostic: <C extends "http-verb-duplicate" | "http-verb-wr
|
|
|
115
118
|
"shared-boolean": {
|
|
116
119
|
readonly default: "shared parameter must be a boolean.";
|
|
117
120
|
};
|
|
121
|
+
"shared-inconsistency": {
|
|
122
|
+
readonly default: "All shared routes must agree on the value of the shared parameter.";
|
|
123
|
+
};
|
|
118
124
|
"write-visibility-not-supported": {
|
|
119
125
|
readonly default: "@visibility(\"write\") is not supported. Use @visibility(\"update\"), @visibility(\"create\") or @visibility(\"create\", \"update\") as appropriate.";
|
|
120
126
|
};
|
|
@@ -179,6 +185,9 @@ declare const reportDiagnostic: <C extends "http-verb-duplicate" | "http-verb-wr
|
|
|
179
185
|
"shared-boolean": {
|
|
180
186
|
readonly default: "shared parameter must be a boolean.";
|
|
181
187
|
};
|
|
188
|
+
"shared-inconsistency": {
|
|
189
|
+
readonly default: "All shared routes must agree on the value of the shared parameter.";
|
|
190
|
+
};
|
|
182
191
|
"write-visibility-not-supported": {
|
|
183
192
|
readonly default: "@visibility(\"write\") is not supported. Use @visibility(\"update\"), @visibility(\"create\") or @visibility(\"create\", \"update\") as appropriate.";
|
|
184
193
|
};
|
|
@@ -191,7 +200,7 @@ declare const reportDiagnostic: <C extends "http-verb-duplicate" | "http-verb-wr
|
|
|
191
200
|
"query-format-required": {
|
|
192
201
|
readonly default: "A format must be specified for @query when type is an array. e.g. @query({format: \"multi\"})";
|
|
193
202
|
};
|
|
194
|
-
}, C, M>) => void, createDiagnostic: <C extends "http-verb-duplicate" | "http-verb-wrong-type" | "missing-path-param" | "optional-path-param" | "missing-server-param" | "duplicate-body" | "duplicate-route-decorator" | "operation-param-duplicate-type" | "duplicate-operation" | "status-code-invalid" | "content-type-string" | "duplicate-response" | "content-type-ignored" | "no-routes" | "invalid-type-for-auth" | "shared-boolean" | "write-visibility-not-supported" | "multipart-model" | "header-format-required" | "query-format-required", M extends keyof {
|
|
203
|
+
}, C, M>) => void, createDiagnostic: <C extends "http-verb-duplicate" | "http-verb-wrong-type" | "missing-path-param" | "optional-path-param" | "missing-server-param" | "duplicate-body" | "duplicate-route-decorator" | "operation-param-duplicate-type" | "duplicate-operation" | "status-code-invalid" | "content-type-string" | "duplicate-response" | "content-type-ignored" | "no-routes" | "invalid-type-for-auth" | "shared-boolean" | "shared-inconsistency" | "write-visibility-not-supported" | "multipart-model" | "header-format-required" | "query-format-required", M extends keyof {
|
|
195
204
|
"http-verb-duplicate": {
|
|
196
205
|
readonly default: import("@typespec/compiler").CallableMessage<["entityName"]>;
|
|
197
206
|
};
|
|
@@ -243,6 +252,9 @@ declare const reportDiagnostic: <C extends "http-verb-duplicate" | "http-verb-wr
|
|
|
243
252
|
"shared-boolean": {
|
|
244
253
|
readonly default: "shared parameter must be a boolean.";
|
|
245
254
|
};
|
|
255
|
+
"shared-inconsistency": {
|
|
256
|
+
readonly default: "All shared routes must agree on the value of the shared parameter.";
|
|
257
|
+
};
|
|
246
258
|
"write-visibility-not-supported": {
|
|
247
259
|
readonly default: "@visibility(\"write\") is not supported. Use @visibility(\"update\"), @visibility(\"create\") or @visibility(\"create\", \"update\") as appropriate.";
|
|
248
260
|
};
|
|
@@ -307,6 +319,9 @@ declare const reportDiagnostic: <C extends "http-verb-duplicate" | "http-verb-wr
|
|
|
307
319
|
"shared-boolean": {
|
|
308
320
|
readonly default: "shared parameter must be a boolean.";
|
|
309
321
|
};
|
|
322
|
+
"shared-inconsistency": {
|
|
323
|
+
readonly default: "All shared routes must agree on the value of the shared parameter.";
|
|
324
|
+
};
|
|
310
325
|
"write-visibility-not-supported": {
|
|
311
326
|
readonly default: "@visibility(\"write\") is not supported. Use @visibility(\"update\"), @visibility(\"create\") or @visibility(\"create\", \"update\") as appropriate.";
|
|
312
327
|
};
|
package/dist/src/lib.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../../src/lib.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../../src/lib.ts"],"names":[],"mappings":"AA6IA,QAAA,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAAuC,CAAC;AACrD,QAAA,MAAQ,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAAE,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sDAAE,iBAAiB,0BAAY,CAAC;AAE1E,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,CAAC"}
|
package/dist/src/lib.js
CHANGED
|
@@ -101,6 +101,12 @@ const libDefinition = {
|
|
|
101
101
|
default: "shared parameter must be a boolean.",
|
|
102
102
|
},
|
|
103
103
|
},
|
|
104
|
+
"shared-inconsistency": {
|
|
105
|
+
severity: "error",
|
|
106
|
+
messages: {
|
|
107
|
+
default: "All shared routes must agree on the value of the shared parameter.",
|
|
108
|
+
},
|
|
109
|
+
},
|
|
104
110
|
"write-visibility-not-supported": {
|
|
105
111
|
severity: "warning",
|
|
106
112
|
messages: {
|
package/dist/src/lib.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib.js","sourceRoot":"","sources":["../../src/lib.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEzE,MAAM,aAAa,GAAG;IACpB,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE;QACX,qBAAqB,EAAE;YACrB,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE;gBACR,OAAO,EAAE,YAAY,CAAA,gCAAgC,YAAY,EAAE;aACpE;SACF;QACD,sBAAsB,EAAE;YACtB,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE;gBACR,OAAO,EAAE,YAAY,CAAA,eAAe,MAAM,SAAS,YAAY,EAAE;aAClE;SACF;QACD,oBAAoB,EAAE;YACpB,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE;gBACR,OAAO,EAAE,YAAY,CAAA,2BAA2B,OAAO,uCAAuC;aAC/F;SACF;QACD,qBAAqB,EAAE;YACrB,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE;gBACR,OAAO,EAAE,YAAY,CAAA,mBAAmB,WAAW,uBAAuB;aAC3E;SACF;QACD,sBAAsB,EAAE;YACtB,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE;gBACR,OAAO,EAAE,YAAY,CAAA,kCAAkC,OAAO,wCAAwC;aACvG;SACF;QACD,gBAAgB,EAAE;YAChB,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE;gBACR,OAAO,EAAE,kDAAkD;gBAC3D,oBAAoB,EAClB,4FAA4F;gBAC9F,kBAAkB,EAChB,iGAAiG;aACpG;SACF;QACD,2BAA2B,EAAE;YAC3B,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE;gBACR,SAAS,EAAE,s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EACL,kHAAkH;aACrH;SACF;QACD,uBAAuB,EAAE;YACvB,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE;gBACR,OAAO,EAAE,YAAY,CAAA,YAAY,MAAM,sEAAsE;aAC9G;SACF;QACD,gBAAgB,EAAE;YAChB,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE;gBACR,OAAO,EAAE,qCAAqC;aAC/C;SACF;QACD,sBAAsB,EAAE;YACtB,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE;gBACR,OAAO,EAAE,oEAAoE;aAC9E;SACF;QACD,gCAAgC,EAAE;YAChC,QAAQ,EAAE,SAAS;YACnB,QAAQ,EAAE;gBACR,OAAO,EAAE,4IAA4I;aACtJ;SACF;QACD,iBAAiB,EAAE;YACjB,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE;gBACR,OAAO,EAAE,yCAAyC;aACnD;SACF;QACD,wBAAwB,EAAE;YACxB,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE;gBACR,OAAO,EAAE,6FAA6F;aACvG;SACF;QACD,uBAAuB,EAAE;YACvB,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE;gBACR,OAAO,EAAE,6FAA6F;aACvG;SACF;KACF;CACO,CAAC;AAEX,MAAM,OAAO,GAAG,qBAAqB,CAAC,aAAa,CAAC,CAAC;AACrD,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC;AAE1E,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAK7C,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,QAsB3C"}
|
package/dist/src/validate.js
CHANGED
|
@@ -1,9 +1,28 @@
|
|
|
1
|
+
import { reportDiagnostic } from "./lib.js";
|
|
1
2
|
import { getAllHttpServices } from "./operations.js";
|
|
3
|
+
import { isSharedRoute } from "./route.js";
|
|
2
4
|
export function $onValidate(program) {
|
|
3
5
|
// Pass along any diagnostics that might be returned from the HTTP library
|
|
4
|
-
const [, diagnostics] = getAllHttpServices(program);
|
|
6
|
+
const [services, diagnostics] = getAllHttpServices(program);
|
|
5
7
|
if (diagnostics.length > 0) {
|
|
6
8
|
program.reportDiagnostics(diagnostics);
|
|
7
9
|
}
|
|
10
|
+
for (const service of services) {
|
|
11
|
+
const paths = new Map();
|
|
12
|
+
for (const operation of service.operations) {
|
|
13
|
+
const path = operation.path;
|
|
14
|
+
const shared = isSharedRoute(program, operation.operation);
|
|
15
|
+
const val = paths.get(path);
|
|
16
|
+
if (shared && val === undefined) {
|
|
17
|
+
paths.set(path, shared);
|
|
18
|
+
}
|
|
19
|
+
else if (val && val !== shared) {
|
|
20
|
+
reportDiagnostic(program, {
|
|
21
|
+
code: "shared-inconsistency",
|
|
22
|
+
target: operation.operation,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
8
27
|
}
|
|
9
28
|
//# sourceMappingURL=validate.js.map
|
package/dist/src/validate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/validate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/validate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,UAAU,WAAW,CAAC,OAAgB;IAC1C,0EAA0E;IAC1E,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAC5D,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE;QAC1B,OAAO,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;KACxC;IACD,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;QAC9B,MAAM,KAAK,GAAG,IAAI,GAAG,EAAmB,CAAC;QACzC,KAAK,MAAM,SAAS,IAAI,OAAO,CAAC,UAAU,EAAE;YAC1C,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC;YAC5B,MAAM,MAAM,GAAG,aAAa,CAAC,OAAO,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;YAC3D,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC5B,IAAI,MAAM,IAAI,GAAG,KAAK,SAAS,EAAE;gBAC/B,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;aACzB;iBAAM,IAAI,GAAG,IAAI,GAAG,KAAK,MAAM,EAAE;gBAChC,gBAAgB,CAAC,OAAO,EAAE;oBACxB,IAAI,EAAE,sBAAsB;oBAC5B,MAAM,EAAE,SAAS,CAAC,SAAS;iBAC5B,CAAC,CAAC;aACJ;SACF;KACF;AACH,CAAC"}
|
package/lib/http-decorators.tsp
CHANGED
|
@@ -164,7 +164,7 @@ extern dec head(target: Operation);
|
|
|
164
164
|
/**
|
|
165
165
|
* Specify the endpoint for this service.
|
|
166
166
|
* @param url Server endpoint
|
|
167
|
-
* @param
|
|
167
|
+
* @param description Description of the endpoint
|
|
168
168
|
* @param parameters Optional set of parameters used to interpolate the url.
|
|
169
169
|
*
|
|
170
170
|
* @example
|
|
@@ -204,3 +204,17 @@ extern dec useAuth(target: Namespace, auth: object | Union | object[]);
|
|
|
204
204
|
* Specify if inapplicable metadata should be included in the payload for the given entity.
|
|
205
205
|
*/
|
|
206
206
|
extern dec includeInapplicableMetadataInPayload(target: unknown, value: boolean);
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* `@route` defines the relative route URI for the target operation
|
|
210
|
+
*
|
|
211
|
+
* The first argument should be a URI fragment that may contain one or more path parameter fields.
|
|
212
|
+
* If the namespace or interface that contains the operation is also marked with a `@route` decorator,
|
|
213
|
+
* it will be used as a prefix to the route URI of the operation.
|
|
214
|
+
*
|
|
215
|
+
* `@route` can only be applied to operations, namespaces, and interfaces.
|
|
216
|
+
*
|
|
217
|
+
* @param path Relative route path. Cannot include query parameters.
|
|
218
|
+
* @param parameters Optional set of parameters used to configure the route. Supports `{shared: true}` which indicates that the route may be shared by several operations.
|
|
219
|
+
*/
|
|
220
|
+
extern dec route(entity: unknown, path: string, parameters?: object);
|
package/lib/http.tsp
CHANGED
|
@@ -6,6 +6,11 @@ namespace TypeSpec.Http;
|
|
|
6
6
|
|
|
7
7
|
using Private;
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Describes an HTTP response.
|
|
11
|
+
*
|
|
12
|
+
* @template Status The status code of the response.
|
|
13
|
+
*/
|
|
9
14
|
model Response<Status> {
|
|
10
15
|
@doc("The status code.")
|
|
11
16
|
@statusCode
|
|
@@ -17,6 +22,8 @@ model Response<Status> {
|
|
|
17
22
|
*
|
|
18
23
|
* This can be useful in situations where you cannot use a bare T as the body
|
|
19
24
|
* and it is awkward to add a property.
|
|
25
|
+
*
|
|
26
|
+
* @template T The type of the model's `body` property.
|
|
20
27
|
*/
|
|
21
28
|
model Body<T> {
|
|
22
29
|
@body
|
|
@@ -49,7 +56,8 @@ model ConflictResponse is Response<409>;
|
|
|
49
56
|
|
|
50
57
|
/**
|
|
51
58
|
* Produces a new model with the same properties as T, but with `@query`,
|
|
52
|
-
|
|
59
|
+
* `@header`, `@body`, and `@path` decorators removed from all properties.
|
|
60
|
+
* @template T The model to spread as the plain data.
|
|
53
61
|
*/
|
|
54
62
|
@plainData
|
|
55
63
|
model PlainData<T> {
|