This commit is contained in:
@@ -770,9 +770,8 @@
|
||||
|
||||
<div class="doc doc-contents first">
|
||||
|
||||
<p>OpenAPI-first application bootstrap for FastAPI.</p>
|
||||
<hr />
|
||||
<h4 id="openapi_first.app--summary">Summary</h4>
|
||||
<h3 id="openapi_first.app--summary">Summary</h3>
|
||||
<p>OpenAPI-first application bootstrap for FastAPI.</p>
|
||||
<p>This module provides <code>OpenAPIFirstApp</code>, a thin but strict abstraction
|
||||
that enforces OpenAPI as the single source of truth for a FastAPI service.</p>
|
||||
|
||||
@@ -784,23 +783,33 @@ that enforces OpenAPI as the single source of truth for a FastAPI service.</p>
|
||||
<span class="normal">2</span>
|
||||
<span class="normal">3</span>
|
||||
<span class="normal">4</span>
|
||||
<span class="normal">5</span></pre></div></td><td class="code"><div><pre><span></span><code>- The OpenAPI specification (JSON or YAML) defines the entire API surface
|
||||
- Every operationId in the OpenAPI spec must have a corresponding Python handler function
|
||||
- Handlers are plain Python callables (no FastAPI decorators)
|
||||
- FastAPI route registration is derived exclusively from the spec
|
||||
- FastAPI's autogenerated OpenAPI schema is fully overridden
|
||||
<span class="normal">5</span>
|
||||
<span class="normal">6</span></pre></div></td><td class="code"><div><pre><span></span><code>- The OpenAPI specification (JSON or YAML) defines the entire API surface.
|
||||
- Every `operationId` in the OpenAPI spec must have a corresponding
|
||||
Python handler function.
|
||||
- Handlers are plain Python callables (no FastAPI decorators).
|
||||
- FastAPI route registration is derived exclusively from the spec.
|
||||
- FastAPI's autogenerated OpenAPI schema is fully overridden.
|
||||
</code></pre></div></td></tr></table></div>
|
||||
<p><strong>Responsibilities:</strong></p>
|
||||
<div class="language-text highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal">1</span>
|
||||
<span class="normal">2</span>
|
||||
<span class="normal">3</span>
|
||||
<span class="normal">4</span></pre></div></td><td class="code"><div><pre><span></span><code>- Loads and validates an OpenAPI 3.x specification
|
||||
- Dynamically binds HTTP routes to handler functions using operationId
|
||||
- Registers routes with FastAPI at application startup
|
||||
- Ensures runtime behavior matches the OpenAPI contract exactly
|
||||
<span class="normal">4</span></pre></div></td><td class="code"><div><pre><span></span><code>- Loads and validates an OpenAPI 3.x specification.
|
||||
- Dynamically binds HTTP routes to handler functions using `operationId`.
|
||||
- Registers routes with FastAPI at application startup.
|
||||
- Ensures runtime behavior matches the OpenAPI contract exactly.
|
||||
</code></pre></div></td></tr></table></div>
|
||||
<p><strong>Constraints:</strong></p>
|
||||
<div class="language-text highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><code>- This module intentionally does NOT: Generate OpenAPI specs, generate client code, introduce a new framework or lifecycle, or alter FastAPI dependency injection semantics.
|
||||
<div class="language-text highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal">1</span>
|
||||
<span class="normal">2</span>
|
||||
<span class="normal">3</span>
|
||||
<span class="normal">4</span>
|
||||
<span class="normal">5</span></pre></div></td><td class="code"><div><pre><span></span><code>- This module intentionally does NOT:
|
||||
- Generate OpenAPI specs.
|
||||
- Generate client code.
|
||||
- Introduce a new framework or lifecycle.
|
||||
- Alter FastAPI dependency injection semantics.
|
||||
</code></pre></div></td></tr></table></div>
|
||||
</details>
|
||||
|
||||
@@ -838,17 +847,23 @@ that enforces OpenAPI as the single source of truth for a FastAPI service.</p>
|
||||
<summary>Notes</summary>
|
||||
<p><strong>Responsibilities:</strong></p>
|
||||
<div class="language-text highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal">1</span>
|
||||
<span class="normal">2</span></pre></div></td><td class="code"><div><pre><span></span><code>- `OpenAPIFirstApp` subclasses FastAPI and replaces manual route registration with OpenAPI-driven binding
|
||||
- All routes are derived from the provided OpenAPI specification, and each operationId is mapped to a Python function in the supplied routes module
|
||||
<span class="normal">2</span>
|
||||
<span class="normal">3</span>
|
||||
<span class="normal">4</span>
|
||||
<span class="normal">5</span></pre></div></td><td class="code"><div><pre><span></span><code>- `OpenAPIFirstApp` subclasses `FastAPI` and replaces manual route
|
||||
registration with OpenAPI-driven binding.
|
||||
- All routes are derived from the provided OpenAPI specification,
|
||||
and each `operationId` is mapped to a Python function in the
|
||||
supplied routes module.
|
||||
</code></pre></div></td></tr></table></div>
|
||||
<p><strong>Guarantees:</strong></p>
|
||||
<div class="language-text highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal">1</span>
|
||||
<span class="normal">2</span>
|
||||
<span class="normal">3</span>
|
||||
<span class="normal">4</span></pre></div></td><td class="code"><div><pre><span></span><code>- No route can exist without an OpenAPI declaration
|
||||
- No OpenAPI operation can exist without a handler
|
||||
- Swagger UI and `/openapi.json` always reflect the provided spec
|
||||
- Handler functions remain framework-agnostic and testable
|
||||
<span class="normal">4</span></pre></div></td><td class="code"><div><pre><span></span><code>- No route can exist without an OpenAPI declaration.
|
||||
- No OpenAPI operation can exist without a handler.
|
||||
- Swagger UI and `/openapi.json` always reflect the provided spec.
|
||||
- Handler functions remain framework-agnostic and testable.
|
||||
</code></pre></div></td></tr></table></div>
|
||||
</details>
|
||||
|
||||
@@ -892,7 +907,8 @@ that enforces OpenAPI as the single source of truth for a FastAPI service.</p>
|
||||
</td>
|
||||
<td>
|
||||
<div class="doc-md-description">
|
||||
<p>Filesystem path to the OpenAPI 3.x specification file. This specification is treated as the authoritative API contract.</p>
|
||||
<p>Filesystem path to the OpenAPI 3.x specification file. This
|
||||
specification is treated as the authoritative API contract.</p>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
@@ -906,7 +922,8 @@ that enforces OpenAPI as the single source of truth for a FastAPI service.</p>
|
||||
</td>
|
||||
<td>
|
||||
<div class="doc-md-description">
|
||||
<p>Python module containing handler functions whose names correspond exactly to OpenAPI operationId values.</p>
|
||||
<p>Python module containing handler functions whose names correspond
|
||||
exactly to OpenAPI <code>operationId</code> values.</p>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
@@ -920,7 +937,9 @@ that enforces OpenAPI as the single source of truth for a FastAPI service.</p>
|
||||
</td>
|
||||
<td>
|
||||
<div class="doc-md-description">
|
||||
<p>Additional keyword arguments passed directly to <code>fastapi.FastAPI</code> (e.g., title, version, middleware, lifespan handlers).</p>
|
||||
<p>Additional keyword arguments passed directly to
|
||||
<code>fastapi.FastAPI</code> (e.g., title, version, middleware, lifespan
|
||||
handlers).</p>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
@@ -946,7 +965,8 @@ that enforces OpenAPI as the single source of truth for a FastAPI service.</p>
|
||||
</td>
|
||||
<td>
|
||||
<div class="doc-md-description">
|
||||
<p>If the OpenAPI specification is invalid, or if any declared operationId does not have a corresponding handler function.</p>
|
||||
<p>If the OpenAPI specification is invalid, or if any declared
|
||||
<code>operationId</code> does not have a corresponding handler function.</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user