typespec-http-zod 0.30.0 → 0.31.0
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 +19 -0
- package/dist/src/api.d.ts +31 -0
- package/dist/src/api.js +1443 -360
- package/dist/src/constraints.d.ts +31 -2
- package/dist/src/constraints.js +242 -46
- package/dist/src/lib.d.ts +136 -13
- package/dist/src/lib.js +167 -18
- package/dist/src/published.d.ts +139 -0
- package/dist/src/published.js +798 -0
- package/dist/src/registry.d.ts +77 -45
- package/dist/src/registry.js +759 -198
- package/dist/src/types.d.ts +12 -2
- package/dist/src/types.js +267 -92
- package/dist/src/uri-template.d.ts +110 -8
- package/dist/src/uri-template.js +251 -46
- package/dist/src/zod.d.ts +715 -39
- package/dist/src/zod.js +4029 -547
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -193,6 +193,25 @@ break the build until the validator and the contract type diverge.
|
|
|
193
193
|
Identifiers are named from the operation id the document publishes. An operation inside a namespace
|
|
194
194
|
carries the whole id, so `op readWidget` in `namespace Widgets` becomes `Widgets_readWidgetPath`.
|
|
195
195
|
|
|
196
|
+
Every component the document publishes is declared under its name - `widgetSchema` and `Widget` -
|
|
197
|
+
including the types no operation reaches, which openapi3 publishes at `All`, and those no route
|
|
198
|
+
names, such as a model a merge holds. A type used only by an operation the document leaves out -
|
|
199
|
+
one whose path holds a query string, or an `@overload` on its base operation's endpoint - is
|
|
200
|
+
declared too, as its validators are emitted. A component carries a visibility suffix,
|
|
201
|
+
`WidgetCreate`, only where its type is used at more than one visibility, as openapi3 names it. Four
|
|
202
|
+
names cannot be TypeScript's, and are not: a namespace is dropped, as one module has one, so two
|
|
203
|
+
types of one name in two namespaces are `duplicate-declaration`; a character an identifier cannot
|
|
204
|
+
hold is written `_`, `Hy-phen` as `Hy_phen`, and a name TypeScript refuses for a declaration - a
|
|
205
|
+
reserved word, a predefined type such as `string`, a strict-mode word such as `public`, a type
|
|
206
|
+
operator such as `keyof` - or a name the generated files declare or name for themselves takes a
|
|
207
|
+
trailing `_` - `delete_`, `string_`, `WireReader_`, `ArrayBuffer_`; and
|
|
208
|
+
a scalar is validated inline wherever it is used, since TypeScript cannot carry its constraints. A
|
|
209
|
+
model named `Record`, `Promise`, `Readonly` or `Exclude` keeps its name - the copy a visibility
|
|
210
|
+
template makes of a `Record<T>` instance, which openapi3 publishes as `Record`, included - and every
|
|
211
|
+
generated file names the library's type as `globalThis.Record<...>`. A type published only as a
|
|
212
|
+
reference to another document, by `@useRef`, is refused as `unsupported-type`: the document states
|
|
213
|
+
no schema for it.
|
|
214
|
+
|
|
196
215
|
## Docs
|
|
197
216
|
|
|
198
217
|
- [Guides](docs/guides.md): installing, validating a request, answering with the right body, content
|
package/dist/src/api.d.ts
CHANGED
|
@@ -242,6 +242,11 @@ export interface EmittedRoute {
|
|
|
242
242
|
* hands `pathSchema` the TEXT of that segment (for an exploding `/` expression, of every segment
|
|
243
243
|
* after it), and `pathSchema` undoes the expansion. A segment holding more than one expression is
|
|
244
244
|
* `unsupported`: no segment router can split it.
|
|
245
|
+
*
|
|
246
|
+
* **For a `/` expression this is the only statement of the route there is.** openapi3 cannot
|
|
247
|
+
* publish the operator: `/lx{/v*}` is `/lx{v}` in the document, under `simple` style and its own
|
|
248
|
+
* `invalid-style` warning, which joins an exploded list `1,2` where the route joins it `1/2`. The
|
|
249
|
+
* validator undoes the route's, as `@typespec/http-specs` expects - see `docs/reference.md`.
|
|
245
250
|
*/
|
|
246
251
|
readonly pathSegments: readonly EmittedPathSegment[];
|
|
247
252
|
/**
|
|
@@ -323,6 +328,26 @@ export interface EmittedRoute {
|
|
|
323
328
|
readonly requestTextual: boolean;
|
|
324
329
|
readonly summary: string | undefined;
|
|
325
330
|
readonly requestSchema: string | undefined;
|
|
331
|
+
/**
|
|
332
|
+
* **The body as a URL-encoded form carries it**, where the route also takes it under another media
|
|
333
|
+
* type: each field read from the text a form holds - `n=5` is `5` where `n` is an `int32` - and a
|
|
334
|
+
* key sent more than once read as the list it stands for. A server validates a form body with this
|
|
335
|
+
* and any other with {@link requestSchema}. `undefined` where no form is declared, or where only a
|
|
336
|
+
* form is, when `requestSchema` reads it itself: validated as JSON, every numeric or boolean field
|
|
337
|
+
* of a form refused every conformant request.
|
|
338
|
+
*/
|
|
339
|
+
readonly formRequestSchema?: string;
|
|
340
|
+
/**
|
|
341
|
+
* **The multipart parts whose value is read from text**, each with whether it is JSON alone: every
|
|
342
|
+
* part but a file and raw bytes. A client may send one with a filename all the same - `curl -F
|
|
343
|
+
* 'r=@data.json;type=application/json'` - and a form reader then hands it over as a file, which
|
|
344
|
+
* the part's schema, reading text, refuses. A server reads such a part's text first. Its media type
|
|
345
|
+
* says what the part is, not the filename. `undefined` where the body is not multipart.
|
|
346
|
+
*/
|
|
347
|
+
readonly textParts?: readonly {
|
|
348
|
+
readonly name: string;
|
|
349
|
+
readonly json: boolean;
|
|
350
|
+
}[];
|
|
326
351
|
/**
|
|
327
352
|
* The parameters, split by WHERE they arrive - see `parameterSchemasOf`.
|
|
328
353
|
*
|
|
@@ -502,6 +527,12 @@ export interface RouteSchemaNames {
|
|
|
502
527
|
*/
|
|
503
528
|
readonly cookie?: string | undefined;
|
|
504
529
|
readonly body: string | undefined;
|
|
530
|
+
/**
|
|
531
|
+
* The validator of the body as a URL-encoded form carries it, where it differs from `body`'s - see
|
|
532
|
+
* {@link EmittedRoute.formRequestSchema}. Absent where a form, if one is declared, is validated by
|
|
533
|
+
* `body`.
|
|
534
|
+
*/
|
|
535
|
+
readonly formBody?: string;
|
|
505
536
|
/**
|
|
506
537
|
* The identifier each response's body is declared under, parallel to `EmittedRoute.responses` and
|
|
507
538
|
* in the same order. `schema` is `undefined` exactly where that response carries no body.
|