feat(standards): codify codegen, ship generic Tier-B infra, add get_app_template + prompts; fix docs:// regressions
P0: fix doc:// -> docs:// across standards src/server/registry and regenerate stale mongo-ops bundle. P1: build recipe + spec-first routing now document the openapi-first codegen fast path (models/routes with --inject-request/--package). P4: CRUD template documents the model-vs-document id rule (BaseDocument owns id). P5: authless guidance (omit security keys). P6: template gains generic infra (http_cache, keyed SSE bus, KV port+in-memory+Redis), interfaces/openapi.py + .dockerignore + generic build test registered as components, and a get_app_template tool; genericity matrix marks LLM pool + human-in-loop as reference-app patterns. P7: intake/build/start_app/trial prompts. P8: template ships tests/integration/test_openapi_app_builds.py. Rebuilt standards + openapi-first bundles and re-collected.
This commit is contained in:
@@ -414,6 +414,15 @@
|
||||
</span>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="md-nav__item">
|
||||
<a href="#authless-apps" class="md-nav__link">
|
||||
<span class="md-ellipsis">
|
||||
Authless apps
|
||||
</span>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="md-nav__item">
|
||||
@@ -665,6 +674,15 @@
|
||||
</span>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="md-nav__item">
|
||||
<a href="#authless-apps" class="md-nav__link">
|
||||
<span class="md-ellipsis">
|
||||
Authless apps
|
||||
</span>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="md-nav__item">
|
||||
@@ -763,10 +781,33 @@ can resolve <code>operationId</code> across the whole app:</p>
|
||||
<li>Security is declared once in the spec and enforced by the framework; handlers
|
||||
contain no auth code.</li>
|
||||
</ul>
|
||||
<h2 id="authless-apps">Authless apps</h2>
|
||||
<p>Auth is <strong>deferred</strong> in the standard: the same spec-first app runs with or
|
||||
without it, because security lives entirely in the spec, never in handlers.
|
||||
For an app that needs no auth yet, do <strong>not</strong> invent per-handler auth checks —
|
||||
just omit the security keys:</p>
|
||||
<ul>
|
||||
<li>Remove the top-level <code>security:</code> block.</li>
|
||||
<li>Remove <code>components.securitySchemes</code>.</li>
|
||||
<li>Do <strong>not</strong> add <code>security: []</code> to operations. An explicit empty array is a
|
||||
per-operation <em>override</em> that means "public", and it only matters when a
|
||||
global <code>security</code> block exists. Leaving every operation without a <code>security</code>
|
||||
key is the cleanest authless spec.</li>
|
||||
</ul>
|
||||
<p>The handlers, services, and composition root are unchanged. When auth is needed
|
||||
later, add the global <code>security</code> block and an introspecting dependency; only
|
||||
handlers that must opt out get <code>security: []</code>.</p>
|
||||
<h2 id="codegen">Codegen</h2>
|
||||
<p>The <code>openapi_first</code> library can scaffold models and route stubs from the spec,
|
||||
and ships app templates (CRUD app, model app, service). Prefer codegen over
|
||||
hand-writing boilerplate.</p>
|
||||
<p><code>openapi_first</code> scaffolds models and route stubs from the spec (see the
|
||||
<a href="../01_build_recipe/">Build Recipe</a>, step 3):</p>
|
||||
<div class="language-bash highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-4-1">1</a></span>
|
||||
<span class="normal"><a href="#__codelineno-4-2">2</a></span>
|
||||
<span class="normal"><a href="#__codelineno-4-3">3</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-4-1"><a id="__codelineno-4-1" name="__codelineno-4-1"></a>openapi-first<span class="w"> </span>models<span class="w"> </span>openapi.yaml<span class="w"> </span>-o<span class="w"> </span>_gen/models.py
|
||||
</span><span id="__span-4-2"><a id="__codelineno-4-2" name="__codelineno-4-2"></a>openapi-first<span class="w"> </span>routes<span class="w"> </span>openapi.yaml<span class="w"> </span>-o<span class="w"> </span>_gen/routes<span class="w"> </span><span class="se">\</span>
|
||||
</span><span id="__span-4-3"><a id="__codelineno-4-3" name="__codelineno-4-3"></a><span class="w"> </span>--use-models<span class="w"> </span>--models-module<span class="w"> </span>_gen.models<span class="w"> </span>--inject-request<span class="w"> </span>--package
|
||||
</span></code></pre></div></td></tr></table></div>
|
||||
<p>Prefer codegen over hand-writing boilerplate. The result is the wire contract
|
||||
and a set of <code>operationId</code>-named signatures — not the canonical handlers.</p>
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user