From 4c4d52e3decfce89b91cab908486e0c4f5b448c6 Mon Sep 17 00:00:00 2001 From: Uwe Schuster Date: Tue, 5 May 2026 21:22:30 +0200 Subject: [PATCH] postprocess-openapi: strip empty `required: []` arrays oatpp 1.3 emits `"required": []` on schemas with no required fields. OpenAPI 3.0.x rejects this with "must NOT have fewer than 1 items", which silently breaks strict consumers. Orval's typed fetch client swallowed it (the violation surfaces only as a non-fatal warning), but Orval's Zod generator (added downstream in fewo-webapp's #469 increment 2) fails hard: must NOT have fewer than 1 items at /components/schemas//required must have required property '$ref' at /components/schemas/ must match exactly one schema in oneOf at /components/schemas/ 83 of fewo-webapp's 198 DTOs trip this. Stripping the empty array (absence of the keyword has the same semantics) is the spec-compliant fix. Bumps to v0.4.1. Co-Authored-By: Claude Opus 4.7 (1M context) --- bin/postprocess-openapi.py | 14 +++++++++++++- package.json | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/bin/postprocess-openapi.py b/bin/postprocess-openapi.py index 552cfcb..5a6a966 100755 --- a/bin/postprocess-openapi.py +++ b/bin/postprocess-openapi.py @@ -43,5 +43,17 @@ for path, methods in paths.items(): op.setdefault("operationId", op_id(method, path)) op.setdefault("tags", [path.strip("/").split("/")[1] if "/" in path.strip("/") else "default"]) +# oatpp 1.3 emits `"required": []` on schemas that have no required fields. +# OpenAPI 3.0.x rejects this (`must NOT have fewer than 1 items`), which +# breaks strict consumers like Orval's Zod generator. Strip empty arrays — +# absence of the keyword has the same semantics. +schemas = spec.get("components", {}).get("schemas", {}) +stripped = 0 +for sch in schemas.values(): + if isinstance(sch, dict) and sch.get("required") == []: + del sch["required"] + stripped += 1 + SRC.write_text(json.dumps(spec, indent=2)) -print(f" postprocessed {SRC} — {len(paths)} paths") +print(f" postprocessed {SRC} — {len(paths)} paths" + + (f", stripped empty `required` from {stripped} schemas" if stripped else "")) diff --git a/package.json b/package.json index 564f14c..ad527b1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@uschuster/webapp-scaffold", - "version": "0.4.0", + "version": "0.4.1", "description": "Shared build scripts + Vite config factories for webapp-template-derived projects.", "type": "module", "bin": {