diff --git a/docs/manual/01-add-a-feature.md b/docs/manual/01-add-a-feature.md index 17121c2a..b790a13c 100644 --- a/docs/manual/01-add-a-feature.md +++ b/docs/manual/01-add-a-feature.md @@ -269,6 +269,7 @@ DTO와 problem details(`type`·`title`·`status`)를 감싸지 않고 보내는 - `boundary`: descriptor의 입력·응답·실패 검증기와 라우트의 `paramsSchema`·`searchSchema`에서 쓰인 자리로 정해진다. 다르면 `: row <적은 값>, used as <맞는 값>`으로 실패한다. 쓰이는데 행이 없으면 `: no FE-REG-SCHEMA row`. - `direction`: 입력은 `REQUEST`, 응답·실패는 `RESPONSE`. - `unknownFieldPolicy`: zod가 모르는 키를 거부하면(`.strict()`) `REJECT_UNKNOWN`, 버리면(`.strip()`) `STRIP_UNKNOWN`. +- descriptor의 입력·응답·실패 검증기로 쓰인 스키마의 행은 `direction`·`unknownFieldPolicy`를 빼지 않는다. 빼면 `row states no direction` 또는 `row states no unknownFieldPolicy`로 실패한다(1106/07-02). 칸이 없으면 응답 DTO를 `.strict()`로 바꿔도 행이 바뀌지 않아 `check:registries`가 breaking으로 보지 못한다. 라우트에만 쓰이는 행은 두 칸이 없어도 된다. - 이 테스트는 설치된 기능을 읽는다. 기능을 더한 상태에서 `test:unit`을 돌릴 때 잡힌다. 예: 공지 기능의 검색값 GET과 경로 파라미터 GET. 입력에 관한 칸과 응답 모양 줄만 적었다. diff --git a/docs/manual/reference/errors.md b/docs/manual/reference/errors.md index 8f4a9af9..910fa46c 100644 --- a/docs/manual/reference/errors.md +++ b/docs/manual/reference/errors.md @@ -86,6 +86,7 @@ lint / check:architecture / check:i18n → FE-GATE-002, FE-GATE-010 | `duplicate operation: ` (계약 조립 오류의 `reason`) | operation ID 중복 | `contracts/-contract-contribution.ts`. 접두어를 붙인다 | | `FE-REG-API..requestSchema references unknown FE-REG-SCHEMA.schemaId=` | descriptor의 입력 스키마 ID가 스키마 메타데이터에 없다 (`responseSchema`, `problemSchema`도 같은 꼴. 실패 본문 행은 `boundary: "api-problem"`) | `contracts/-schema-metadata.ts` | | `: row , used as ` (`tests/unit/schema-metadata-policy.test.ts`) | 스키마 메타 행의 `boundary`가 그 스키마가 쓰인 자리와 다르다. `no FE-REG-SCHEMA row`는 쓰이는데 행이 없다 | `contracts/-schema-metadata.ts` | +| ` : row states no direction, used as ` 또는 `row states no unknownFieldPolicy, validator ` (`tests/unit/schema-metadata-policy.test.ts`) | descriptor가 쓰는 스키마의 행이 `direction`·`unknownFieldPolicy`를 적지 않았다(1106/07-02) | `contracts/-schema-metadata.ts`에 두 칸을 적는다. 값은 쓰인 자리와 검증기가 정한다 | | `Unregistered route codec: ` | URL 함수가 기능 codec을 `buildRouteUrl`에 넘기지 않았다 | `presentation/-routes.ts` | | `contract package is declared, but no loaded contribution pins it` | 계약 `contractPackages`에 적은 패키지를 계약 기여가 쓰지 않는다 | `contracts/-contract-contribution.ts`의 `source` | | ` contributes contract package , which no installed feature declares in contracts.contractPackages` | 계약 기여의 신원과 계약 선언의 신원이 다르다 | 둘 다 `_CONTRACT_PACKAGE` 하나를 쓰게 한다 | diff --git a/tests/unit/schema-metadata-policy.test.ts b/tests/unit/schema-metadata-policy.test.ts index 287271f6..f33f0e88 100644 --- a/tests/unit/schema-metadata-policy.test.ts +++ b/tests/unit/schema-metadata-policy.test.ts @@ -21,6 +21,13 @@ import { * `unrecognized_keys` rejects unknown fields; one that reaches the object * without that issue tolerates them. A nested object below that level is not * probed. + * + * 1106/07-02. Both fields are optional in the row type, and a row that left + * them out used to be skipped here. 1105/07-02 grades a response row whose + * policy turns `REJECT_UNKNOWN` as breaking, but a row with no policy does not + * change when its DTO turns `.strict()`, so nothing saw it. A schema an HTTP + * operation uses now fails here without them. Route-only rows (`NotFoundSplat`) + * are not in `slots` and still need neither. */ const PROBE_KEY = "__unknownFieldProbe"; @@ -127,9 +134,11 @@ describe("FE-REG-SCHEMA policy of the installed HTTP schemas (1103/07-03)", () = it("declares the direction each schema is used in", () => { const wrong = slots.flatMap(({ operationId, direction, validator }) => { const declared = SCHEMA_REGISTRY[validator.schemaId]?.direction; - return declared === undefined || declared === direction + return declared === direction ? [] - : [`${operationId} ${validator.schemaId}: row ${declared}, used as ${direction}`]; + : [ + `${operationId} ${validator.schemaId}: row ${declared ?? "states no direction"}, used as ${direction}`, + ]; }); expect(wrong).toEqual([]); @@ -154,11 +163,12 @@ describe("FE-REG-SCHEMA policy of the installed HTTP schemas (1103/07-03)", () = it("declares the unknown-field policy its validator applies", () => { const wrong = slots.flatMap(({ operationId, validator }) => { const declared = SCHEMA_REGISTRY[validator.schemaId]?.unknownFieldPolicy; - if (declared === undefined) return []; const probed = probeUnknownFieldPolicy(validator); return probed === declared ? [] - : [`${operationId} ${validator.schemaId}: row ${declared}, validator ${probed}`]; + : [ + `${operationId} ${validator.schemaId}: row ${declared ?? "states no unknownFieldPolicy"}, validator ${probed}`, + ]; }); expect(wrong).toEqual([]);