docs: re-collect wiki sites (doc-forge, openapi-first)
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Reflect rebuilt consumer wikis in the hub: doc-forge gains the MkDocs cross-kind link notes; openapi-first gains the codegen --template-style content. Purely cosmetic (toolchain escaping) and sitemap mtime deltas were left out.
This commit is contained in:
@@ -671,6 +671,15 @@
|
||||
</span>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="md-nav__item">
|
||||
<a href="#handler-shapes" class="md-nav__link">
|
||||
<span class="md-ellipsis">
|
||||
Handler shapes
|
||||
</span>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
@@ -894,6 +903,10 @@
|
||||
<td><code>--package</code></td>
|
||||
<td>Emit <code><resource>/routes.py</code> packages (with <code>__init__.py</code>) instead of flat <code><resource>.py</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>--template-style</code></td>
|
||||
<td>Emit <code>async def</code> handlers with a JSON body parameter named <code>body</code> (the standards-template convention) plus a service-resolution hint, instead of sync <code>def</code> handlers taking <code>payload</code></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>Why bother? Because <code>bind_routes</code> (in <a href="../../02_components/">02 – Components</a>) needs an <code>operationId</code> → handler <strong>exactly</strong> matching the spec. Codegen guarantees you never type a handler name wrong — it wears the same <code>operationId</code> the spec declares.</p>
|
||||
@@ -903,6 +916,13 @@
|
||||
<li><code>multipart/form-data</code> and <code>application/x-www-form-urlencoded</code> bodies expand to one parameter per schema property: <code>UploadFile = File(...)</code> for <code>format: binary</code>, <code>Form(...)</code> otherwise — not an opaque <code>payload: dict</code>. Fields are required only when listed in the schema's <code>required</code>.</li>
|
||||
</ul>
|
||||
<p>The stubs <code>raise NotImplementedError</code>; fill each body in (typically by resolving a service from <code>request.app.state</code>).</p>
|
||||
<h3 id="handler-shapes">Handler shapes</h3>
|
||||
<p>Both shapes bind equally — the router resolves the handler by <code>operationId</code> and introspects the FastAPI signature, so it never inspects the request body:</p>
|
||||
<ul>
|
||||
<li><strong>Default (sync stub):</strong> <code>def create_item(payload: ItemInput, response: Response):</code> — the body parameter is <code>payload</code>.</li>
|
||||
<li><strong><code>--template-style</code>:</strong> <code>async def create_item(request: Request, body: ItemInput, response: Response):</code> — matches the standards template (<code>async def</code>, <code>body</code> parameter, a <code>request.app.state.db_resources["<resource>_svc"]</code> hint).</li>
|
||||
</ul>
|
||||
<p>Use <code>--template-style</code> when generating against the standards template so the scaffold matches the hand-written handlers you will keep.</p>
|
||||
<blockquote>
|
||||
<p><strong>Note:</strong> <code>models</code> / <code>routes</code> are build-time tooling. They do <strong>not</strong> run at runtime, and templates (the Bake-your-stuff section of <a href="../02_templates/">02 – Templates</a>) scaffold a working server out-of-the-box for greenfield projects.</p>
|
||||
</blockquote>
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user