From 6176e2c3adc249412e7b4cb239ec213a4a1bf1ce Mon Sep 17 00:00:00 2001 From: Steffen Sauder Date: Fri, 17 Apr 2026 09:03:33 +0200 Subject: [PATCH] fix: rewrite defineLinks JSDoc example to not crash at runtime The public @example showed `'posts[]': { to: 'posts' }` as a validated link path. After housekeeping #10 hardened validateResourceDefinition to reject bare terminal `[]` segments, copying this example verbatim throws `Array segment 'posts[]' cannot be terminal.` at runtime. Rewrite the example to be self-contained: show UserSchema with a `posts` field of shape `Type.Array(Type.Object({ href: Type.String() }))` and use the `'posts[].href'` link path, matching the canonical idiom used in examples/petshop-api.ts. Addresses FINDING-01 from code review. Co-Authored-By: Claude Opus 4.7 --- src/link-definition.ts | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/src/link-definition.ts b/src/link-definition.ts index 49df768..2b0dfb6 100644 --- a/src/link-definition.ts +++ b/src/link-definition.ts @@ -126,22 +126,36 @@ export type ApiDefinition = Record