|
4 | 4 | import type { JSONSchemaType } from "@typespec/compiler"; |
5 | 5 | import { createTypeSpecLibrary, paramMessage } from "@typespec/compiler"; |
6 | 6 |
|
| 7 | +/** |
| 8 | + * Configures the server bindings generated by the `$onEmit` entry point. |
| 9 | + * |
| 10 | + * Supply these options under `@typespec/http-server-js` in `tspconfig.yaml`. |
| 11 | + * The emitter option schema registered by {@link $lib} defaults all boolean options |
| 12 | + * to `false` and `datetime` to `"temporal-polyfill"`. |
| 13 | + */ |
7 | 14 | export interface JsEmitterOptions { |
8 | | - /** If set to `true`, the emitter will generate a router that exposes an Express.js middleware function in addition to the ordinary Node.js HTTP server router. |
9 | | -
|
10 | | -If this option is not set to `true`, the `expressMiddleware` property will not be present on the generated router. */ |
| 15 | + /** |
| 16 | + * Generates an Express.js middleware adapter in addition to the Node.js HTTP server router. |
| 17 | + * When disabled, the generated router has no `expressMiddleware` property. |
| 18 | + * @default false |
| 19 | + */ |
11 | 20 | express?: boolean; |
12 | 21 |
|
13 | | - /** By default, the emitter will create interfaces that represent all models in the service namespace. If this option is set |
14 | | -to `true`, the emitter will only emit those types that are reachable from an HTTP operation. */ |
| 22 | + /** |
| 23 | + * Limits generated types to those reachable from HTTP operations. By default, types in |
| 24 | + * the service namespace and its nested namespaces are also included. |
| 25 | + * @default false |
| 26 | + */ |
15 | 27 | "omit-unreachable-types": boolean; |
16 | | - /** If set to `true`, the emitter will not format the generated code using Prettier. */ |
| 28 | + /** |
| 29 | + * Skips Prettier formatting of generated source files. |
| 30 | + * @default false |
| 31 | + */ |
17 | 32 | "no-format": boolean; |
18 | 33 |
|
19 | 34 | /** |
20 | | - * The type of datetime models to use for TypeSpecs DateTime and Duration types. |
| 35 | + * Selects the JavaScript representation of TypeSpec date, time, and duration scalars. |
21 | 36 | * |
22 | 37 | * Options: |
23 | 38 | * - `temporal-polyfill`: (Default) Uses the Temporal API from the `temporal-polyfill` package. |
24 | 39 | * - `temporal`: Uses the native Temporal API, requires that your target environment supports it. This will become the default setting in the future. |
25 | 40 | * - `date-duration`: Uses the built-in `Date` and a custom `Duration` type. Not recommended. |
| 41 | + * @default "temporal-polyfill" |
26 | 42 | */ |
27 | 43 | datetime?: "temporal-polyfill" | "temporal" | "date-duration"; |
28 | 44 | } |
@@ -61,6 +77,11 @@ const EmitterOptionsSchema: JSONSchemaType<JsEmitterOptions> = { |
61 | 77 | required: [], |
62 | 78 | }; |
63 | 79 |
|
| 80 | +/** |
| 81 | + * TypeSpec library definition registering the server emitter's option schema, defaults, |
| 82 | + * diagnostics, and dry-run support. Re-exported from the package entry point for the |
| 83 | + * compiler to discover; `$onEmit` performs code generation. |
| 84 | + */ |
64 | 85 | export const $lib = createTypeSpecLibrary({ |
65 | 86 | name: "@typespec/http-server-js", |
66 | 87 | capabilities: { |
|
0 commit comments