function-api-builder 0.1.0__tar.gz → 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,391 @@
1
+ Metadata-Version: 2.4
2
+ Name: function-api-builder
3
+ Version: 0.1.1
4
+ Summary: Generate complete FastAPI applications from decorated Python business functions.
5
+ Author: Sushruth Samson
6
+ License-Expression: MIT
7
+ Keywords: api-builder,api-generator,backend,code-generation,fastapi,pydantic
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Environment :: Console
10
+ Classifier: Framework :: FastAPI
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Software Development :: Code Generators
19
+ Requires-Python: >=3.11
20
+ Requires-Dist: fastapi>=0.115
21
+ Requires-Dist: pydantic>=2.7
22
+ Requires-Dist: uvicorn>=0.30
23
+ Provides-Extra: dev
24
+ Requires-Dist: build>=1.2; extra == 'dev'
25
+ Requires-Dist: httpx>=0.27; extra == 'dev'
26
+ Requires-Dist: mypy>=1.13; extra == 'dev'
27
+ Requires-Dist: pytest>=8; extra == 'dev'
28
+ Requires-Dist: ruff>=0.8; extra == 'dev'
29
+ Requires-Dist: twine>=6; extra == 'dev'
30
+ Description-Content-Type: text/markdown
31
+
32
+ <p align="center">
33
+ <img src="assets/api-builder.svg" alt="API Builder" width="180">
34
+ </p>
35
+
36
+ <h1 align="center">API Builder</h1>
37
+
38
+ <p align="center">
39
+ Generate a complete FastAPI application from decorated Python business functions.
40
+ </p>
41
+
42
+ ## Status
43
+
44
+ This project is alpha software. The intended PyPI distribution name is `api-builder`.
45
+ PyPI currently rejects that exact name as too similar to an existing project, so the
46
+ first published release is temporarily available as `function-api-builder` while the
47
+ name issue is resolved.
48
+
49
+ ## Install
50
+
51
+ Intended install command:
52
+
53
+ ```bash
54
+ pip install api-builder
55
+ ```
56
+
57
+ Current published fallback:
58
+
59
+ ```bash
60
+ pip install function-api-builder
61
+ ```
62
+
63
+ Both distributions expose the same Python packages and the same `api-builder` command.
64
+
65
+ ## What It Does
66
+
67
+ API Builder turns plain, typed business functions into a runnable FastAPI service.
68
+ You write the business logic once. The builder discovers those functions, validates
69
+ their metadata and Pydantic models, then generates an `app/` directory containing:
70
+
71
+ - public service routes
72
+ - optional local development routes for individual functions
73
+ - request validation through Pydantic
74
+ - service sequencing
75
+ - dependency and request-context containers
76
+ - standard error responses
77
+ - health checks
78
+ - OpenAPI documentation
79
+ - generated smoke tests
80
+
81
+ The generated application is ordinary Python code. After generation, run it with
82
+ Uvicorn or edit the generated app as part of your application workflow.
83
+
84
+ ## End-to-End Flow
85
+
86
+ The complete flow is:
87
+
88
+ ```text
89
+ functions/**/*.py
90
+ |
91
+ | @function metadata + type annotations
92
+ v
93
+ discovery and import
94
+ |
95
+ | signature, models, steps, routes, dependencies
96
+ v
97
+ validation
98
+ |
99
+ | generated Python modules and manifest
100
+ v
101
+ app/ directory
102
+ |
103
+ | FastAPI startup imports generated routers
104
+ v
105
+ HTTP API + OpenAPI
106
+ ```
107
+
108
+ ### 1. Write a business function
109
+
110
+ Business functions live under `functions/`. Every function exposed by the builder
111
+ uses the same three-argument contract:
112
+
113
+ ```python
114
+ def business_function(payload, deps, context) -> OutputModel:
115
+ ...
116
+ ```
117
+
118
+ - `payload` is a Pydantic input model.
119
+ - `deps` is the generated dependency container.
120
+ - `context` contains request metadata and the current service execution context.
121
+ - The return annotation is a Pydantic output model.
122
+
123
+ The function may be synchronous or asynchronous.
124
+
125
+ ### 2. Decorate it with service metadata
126
+
127
+ ```python
128
+ from pydantic import BaseModel
129
+ from api_builder_runtime import function
130
+
131
+
132
+ class EchoInput(BaseModel):
133
+ message: str
134
+
135
+
136
+ class EchoOutput(BaseModel):
137
+ message: str
138
+
139
+
140
+ @function(service="echo", step=1)
141
+ def echo(payload: EchoInput, deps, context) -> EchoOutput:
142
+ return EchoOutput(message=payload.message)
143
+ ```
144
+
145
+ The decorator records the metadata needed by the builder:
146
+
147
+ - `service`: the public service name
148
+ - `step`: execution order inside the service
149
+ - `description`: optional function description
150
+ - `dependencies`: optional named dependencies
151
+ - `errors`: optional application error codes and HTTP statuses
152
+
153
+ The decorator does not execute the function. It marks the function for discovery.
154
+
155
+ ### 3. Run the builder
156
+
157
+ From the root of the project containing `functions/`:
158
+
159
+ ```bash
160
+ api-builder
161
+ ```
162
+
163
+ Useful options:
164
+
165
+ ```bash
166
+ api-builder --check # validate without writing app/
167
+ api-builder --force # overwrite generated files
168
+ api-builder --service echo # generate one service
169
+ api-builder --no-dev-routes # omit local function routes
170
+ api-builder --project-root ./demo # build another project
171
+ ```
172
+
173
+ ### 4. Run the generated API
174
+
175
+ ```bash
176
+ uvicorn app.main:app --reload
177
+ ```
178
+
179
+ The public route for the `echo` service is:
180
+
181
+ ```bash
182
+ curl -X POST http://127.0.0.1:8000/api/v1/echo \
183
+ -H 'content-type: application/json' \
184
+ -d '{"message":"hello"}'
185
+ ```
186
+
187
+ The response uses the generated standard envelope:
188
+
189
+ ```json
190
+ {
191
+ "data": {
192
+ "message": "hello"
193
+ }
194
+ }
195
+ ```
196
+
197
+ OpenAPI is available at `/docs` and `/openapi.json`. Health status is available at
198
+ `/healthz`.
199
+
200
+ ## Multi-Step Services
201
+
202
+ A service can contain multiple functions. Steps run in ascending order, and the
203
+ output of each step becomes the input for the next step.
204
+
205
+ ```python
206
+ class ReadInput(BaseModel):
207
+ file_reference: str
208
+
209
+
210
+ class ReadOutput(BaseModel):
211
+ text: str
212
+
213
+
214
+ class SummarizeInput(BaseModel):
215
+ text: str
216
+
217
+
218
+ class SummarizeOutput(BaseModel):
219
+ summary: str
220
+
221
+
222
+ @function(service="document", step=1)
223
+ async def read_document(
224
+ payload: ReadInput, deps, context
225
+ ) -> ReadOutput:
226
+ return ReadOutput(text="Document contents")
227
+
228
+
229
+ @function(service="document", step=2)
230
+ async def summarize_document(
231
+ payload: SummarizeInput, deps, context
232
+ ) -> SummarizeOutput:
233
+ return SummarizeOutput(summary=payload.text)
234
+ ```
235
+
236
+ The builder validates that:
237
+
238
+ - steps are unique
239
+ - steps are contiguous, starting at `1`
240
+ - required fields needed by the next step are produced by the previous step
241
+ - generated route paths and operation IDs are unique
242
+
243
+ The public route remains one service route:
244
+
245
+ ```text
246
+ POST /api/v1/document
247
+ ```
248
+
249
+ ## Generated Project Layout
250
+
251
+ Running `api-builder` creates this shape:
252
+
253
+ ```text
254
+ app/
255
+ ├── config.py # environment-backed settings
256
+ ├── context.py # request execution context
257
+ ├── dependencies.py # named dependency container
258
+ ├── errors.py # standard exception mapping
259
+ ├── health.py # GET /healthz
260
+ ├── main.py # FastAPI application factory
261
+ ├── middleware.py # request middleware
262
+ ├── responses.py # response envelopes
263
+ ├── routers/
264
+ │ ├── public.py # service routes
265
+ │ └── dev.py # local function routes
266
+ ├── services/ # generated service orchestration
267
+ ├── generated/
268
+ │ ├── function_registry.py # discovered function registry
269
+ │ ├── service_registry.py # service registry
270
+ │ ├── manifest.py # runtime metadata
271
+ │ └── manifest.json # inspectable metadata
272
+ └── tests/ # generated health/OpenAPI tests
273
+ ```
274
+
275
+ Generated files contain a header identifying them as generated. Treat the decorated
276
+ functions under `functions/` as the source of truth and regenerate after changing
277
+ their metadata or type models.
278
+
279
+ ## Development Routes
280
+
281
+ When the environment is `local`, `development`, or `test`, API Builder exposes one
282
+ route per decorated function:
283
+
284
+ ```text
285
+ POST /__dev/functions/{service}/{function}
286
+ ```
287
+
288
+ These routes require the `X-Internal-Dev-Token` header. They are excluded from the
289
+ OpenAPI schema and application entirely in production environments.
290
+
291
+ Use them to exercise a single step while developing a service. The public service
292
+ route remains the normal integration boundary.
293
+
294
+ ## Errors
295
+
296
+ Business functions can raise `FunctionError`:
297
+
298
+ ```python
299
+ from api_builder_runtime import FunctionError
300
+
301
+
302
+ raise FunctionError("EMPTY_DOCUMENT", "The document contains no readable text.")
303
+ ```
304
+
305
+ Declare an error status on the decorator when a custom HTTP status is needed:
306
+
307
+ ```python
308
+ @function(
309
+ service="document",
310
+ step=2,
311
+ errors={"EMPTY_DOCUMENT": 422},
312
+ )
313
+ async def summarize_document(payload, deps, context):
314
+ ...
315
+ ```
316
+
317
+ The generated error handler returns a stable API error shape and avoids exposing
318
+ internal tracebacks or implementation details to clients.
319
+
320
+ ## Validation Rules
321
+
322
+ Build-time validation fails fast when the project contains an invalid function:
323
+
324
+ - missing `functions/` directory
325
+ - no decorated functions
326
+ - wrong function signature
327
+ - missing or invalid Pydantic input model
328
+ - missing or invalid Pydantic output model
329
+ - invalid service or dependency names
330
+ - duplicate or missing service steps
331
+ - incompatible adjacent step models
332
+ - duplicate routes or operation IDs
333
+
334
+ Use `api-builder --check` in CI to validate source functions without changing the
335
+ working tree.
336
+
337
+ ## Example
338
+
339
+ The repository includes a two-step PDF summary example at:
340
+
341
+ ```text
342
+ examples/basic/functions/pdf_summary.py
343
+ ```
344
+
345
+ Build it with:
346
+
347
+ ```bash
348
+ api-builder --project-root examples/basic --force
349
+ ```
350
+
351
+ ## Library API
352
+
353
+ The builder can also be called from Python:
354
+
355
+ ```python
356
+ from pathlib import Path
357
+ from api_builder import build
358
+
359
+
360
+ result = build(Path("."), force=True)
361
+ for route in result.routes:
362
+ print(route.method, route.path)
363
+ ```
364
+
365
+ The runtime decorator is intentionally small and has no application-global registry.
366
+ Discovery happens when the builder scans the current project.
367
+
368
+ ## Local Development
369
+
370
+ ```bash
371
+ python -m venv .venv
372
+ source .venv/bin/activate
373
+ pip install -e '.[dev]'
374
+ pytest
375
+ ruff check src tests examples/basic/functions
376
+ mypy src tests
377
+ python -m build
378
+ python -m twine check dist/*
379
+ ```
380
+
381
+ ## Scope
382
+
383
+ API Builder generates application structure and validates the contract between
384
+ decorated functions. It does not diagnose infrastructure failures, determine root
385
+ cause, repair runtime systems, or create external service clients automatically.
386
+ Dependencies are named in function metadata and represented in the generated app;
387
+ application owners decide how those dependencies are implemented.
388
+
389
+ ## License
390
+
391
+ MIT. See the project metadata for the current author and package version.
@@ -0,0 +1,360 @@
1
+ <p align="center">
2
+ <img src="assets/api-builder.svg" alt="API Builder" width="180">
3
+ </p>
4
+
5
+ <h1 align="center">API Builder</h1>
6
+
7
+ <p align="center">
8
+ Generate a complete FastAPI application from decorated Python business functions.
9
+ </p>
10
+
11
+ ## Status
12
+
13
+ This project is alpha software. The intended PyPI distribution name is `api-builder`.
14
+ PyPI currently rejects that exact name as too similar to an existing project, so the
15
+ first published release is temporarily available as `function-api-builder` while the
16
+ name issue is resolved.
17
+
18
+ ## Install
19
+
20
+ Intended install command:
21
+
22
+ ```bash
23
+ pip install api-builder
24
+ ```
25
+
26
+ Current published fallback:
27
+
28
+ ```bash
29
+ pip install function-api-builder
30
+ ```
31
+
32
+ Both distributions expose the same Python packages and the same `api-builder` command.
33
+
34
+ ## What It Does
35
+
36
+ API Builder turns plain, typed business functions into a runnable FastAPI service.
37
+ You write the business logic once. The builder discovers those functions, validates
38
+ their metadata and Pydantic models, then generates an `app/` directory containing:
39
+
40
+ - public service routes
41
+ - optional local development routes for individual functions
42
+ - request validation through Pydantic
43
+ - service sequencing
44
+ - dependency and request-context containers
45
+ - standard error responses
46
+ - health checks
47
+ - OpenAPI documentation
48
+ - generated smoke tests
49
+
50
+ The generated application is ordinary Python code. After generation, run it with
51
+ Uvicorn or edit the generated app as part of your application workflow.
52
+
53
+ ## End-to-End Flow
54
+
55
+ The complete flow is:
56
+
57
+ ```text
58
+ functions/**/*.py
59
+ |
60
+ | @function metadata + type annotations
61
+ v
62
+ discovery and import
63
+ |
64
+ | signature, models, steps, routes, dependencies
65
+ v
66
+ validation
67
+ |
68
+ | generated Python modules and manifest
69
+ v
70
+ app/ directory
71
+ |
72
+ | FastAPI startup imports generated routers
73
+ v
74
+ HTTP API + OpenAPI
75
+ ```
76
+
77
+ ### 1. Write a business function
78
+
79
+ Business functions live under `functions/`. Every function exposed by the builder
80
+ uses the same three-argument contract:
81
+
82
+ ```python
83
+ def business_function(payload, deps, context) -> OutputModel:
84
+ ...
85
+ ```
86
+
87
+ - `payload` is a Pydantic input model.
88
+ - `deps` is the generated dependency container.
89
+ - `context` contains request metadata and the current service execution context.
90
+ - The return annotation is a Pydantic output model.
91
+
92
+ The function may be synchronous or asynchronous.
93
+
94
+ ### 2. Decorate it with service metadata
95
+
96
+ ```python
97
+ from pydantic import BaseModel
98
+ from api_builder_runtime import function
99
+
100
+
101
+ class EchoInput(BaseModel):
102
+ message: str
103
+
104
+
105
+ class EchoOutput(BaseModel):
106
+ message: str
107
+
108
+
109
+ @function(service="echo", step=1)
110
+ def echo(payload: EchoInput, deps, context) -> EchoOutput:
111
+ return EchoOutput(message=payload.message)
112
+ ```
113
+
114
+ The decorator records the metadata needed by the builder:
115
+
116
+ - `service`: the public service name
117
+ - `step`: execution order inside the service
118
+ - `description`: optional function description
119
+ - `dependencies`: optional named dependencies
120
+ - `errors`: optional application error codes and HTTP statuses
121
+
122
+ The decorator does not execute the function. It marks the function for discovery.
123
+
124
+ ### 3. Run the builder
125
+
126
+ From the root of the project containing `functions/`:
127
+
128
+ ```bash
129
+ api-builder
130
+ ```
131
+
132
+ Useful options:
133
+
134
+ ```bash
135
+ api-builder --check # validate without writing app/
136
+ api-builder --force # overwrite generated files
137
+ api-builder --service echo # generate one service
138
+ api-builder --no-dev-routes # omit local function routes
139
+ api-builder --project-root ./demo # build another project
140
+ ```
141
+
142
+ ### 4. Run the generated API
143
+
144
+ ```bash
145
+ uvicorn app.main:app --reload
146
+ ```
147
+
148
+ The public route for the `echo` service is:
149
+
150
+ ```bash
151
+ curl -X POST http://127.0.0.1:8000/api/v1/echo \
152
+ -H 'content-type: application/json' \
153
+ -d '{"message":"hello"}'
154
+ ```
155
+
156
+ The response uses the generated standard envelope:
157
+
158
+ ```json
159
+ {
160
+ "data": {
161
+ "message": "hello"
162
+ }
163
+ }
164
+ ```
165
+
166
+ OpenAPI is available at `/docs` and `/openapi.json`. Health status is available at
167
+ `/healthz`.
168
+
169
+ ## Multi-Step Services
170
+
171
+ A service can contain multiple functions. Steps run in ascending order, and the
172
+ output of each step becomes the input for the next step.
173
+
174
+ ```python
175
+ class ReadInput(BaseModel):
176
+ file_reference: str
177
+
178
+
179
+ class ReadOutput(BaseModel):
180
+ text: str
181
+
182
+
183
+ class SummarizeInput(BaseModel):
184
+ text: str
185
+
186
+
187
+ class SummarizeOutput(BaseModel):
188
+ summary: str
189
+
190
+
191
+ @function(service="document", step=1)
192
+ async def read_document(
193
+ payload: ReadInput, deps, context
194
+ ) -> ReadOutput:
195
+ return ReadOutput(text="Document contents")
196
+
197
+
198
+ @function(service="document", step=2)
199
+ async def summarize_document(
200
+ payload: SummarizeInput, deps, context
201
+ ) -> SummarizeOutput:
202
+ return SummarizeOutput(summary=payload.text)
203
+ ```
204
+
205
+ The builder validates that:
206
+
207
+ - steps are unique
208
+ - steps are contiguous, starting at `1`
209
+ - required fields needed by the next step are produced by the previous step
210
+ - generated route paths and operation IDs are unique
211
+
212
+ The public route remains one service route:
213
+
214
+ ```text
215
+ POST /api/v1/document
216
+ ```
217
+
218
+ ## Generated Project Layout
219
+
220
+ Running `api-builder` creates this shape:
221
+
222
+ ```text
223
+ app/
224
+ ├── config.py # environment-backed settings
225
+ ├── context.py # request execution context
226
+ ├── dependencies.py # named dependency container
227
+ ├── errors.py # standard exception mapping
228
+ ├── health.py # GET /healthz
229
+ ├── main.py # FastAPI application factory
230
+ ├── middleware.py # request middleware
231
+ ├── responses.py # response envelopes
232
+ ├── routers/
233
+ │ ├── public.py # service routes
234
+ │ └── dev.py # local function routes
235
+ ├── services/ # generated service orchestration
236
+ ├── generated/
237
+ │ ├── function_registry.py # discovered function registry
238
+ │ ├── service_registry.py # service registry
239
+ │ ├── manifest.py # runtime metadata
240
+ │ └── manifest.json # inspectable metadata
241
+ └── tests/ # generated health/OpenAPI tests
242
+ ```
243
+
244
+ Generated files contain a header identifying them as generated. Treat the decorated
245
+ functions under `functions/` as the source of truth and regenerate after changing
246
+ their metadata or type models.
247
+
248
+ ## Development Routes
249
+
250
+ When the environment is `local`, `development`, or `test`, API Builder exposes one
251
+ route per decorated function:
252
+
253
+ ```text
254
+ POST /__dev/functions/{service}/{function}
255
+ ```
256
+
257
+ These routes require the `X-Internal-Dev-Token` header. They are excluded from the
258
+ OpenAPI schema and application entirely in production environments.
259
+
260
+ Use them to exercise a single step while developing a service. The public service
261
+ route remains the normal integration boundary.
262
+
263
+ ## Errors
264
+
265
+ Business functions can raise `FunctionError`:
266
+
267
+ ```python
268
+ from api_builder_runtime import FunctionError
269
+
270
+
271
+ raise FunctionError("EMPTY_DOCUMENT", "The document contains no readable text.")
272
+ ```
273
+
274
+ Declare an error status on the decorator when a custom HTTP status is needed:
275
+
276
+ ```python
277
+ @function(
278
+ service="document",
279
+ step=2,
280
+ errors={"EMPTY_DOCUMENT": 422},
281
+ )
282
+ async def summarize_document(payload, deps, context):
283
+ ...
284
+ ```
285
+
286
+ The generated error handler returns a stable API error shape and avoids exposing
287
+ internal tracebacks or implementation details to clients.
288
+
289
+ ## Validation Rules
290
+
291
+ Build-time validation fails fast when the project contains an invalid function:
292
+
293
+ - missing `functions/` directory
294
+ - no decorated functions
295
+ - wrong function signature
296
+ - missing or invalid Pydantic input model
297
+ - missing or invalid Pydantic output model
298
+ - invalid service or dependency names
299
+ - duplicate or missing service steps
300
+ - incompatible adjacent step models
301
+ - duplicate routes or operation IDs
302
+
303
+ Use `api-builder --check` in CI to validate source functions without changing the
304
+ working tree.
305
+
306
+ ## Example
307
+
308
+ The repository includes a two-step PDF summary example at:
309
+
310
+ ```text
311
+ examples/basic/functions/pdf_summary.py
312
+ ```
313
+
314
+ Build it with:
315
+
316
+ ```bash
317
+ api-builder --project-root examples/basic --force
318
+ ```
319
+
320
+ ## Library API
321
+
322
+ The builder can also be called from Python:
323
+
324
+ ```python
325
+ from pathlib import Path
326
+ from api_builder import build
327
+
328
+
329
+ result = build(Path("."), force=True)
330
+ for route in result.routes:
331
+ print(route.method, route.path)
332
+ ```
333
+
334
+ The runtime decorator is intentionally small and has no application-global registry.
335
+ Discovery happens when the builder scans the current project.
336
+
337
+ ## Local Development
338
+
339
+ ```bash
340
+ python -m venv .venv
341
+ source .venv/bin/activate
342
+ pip install -e '.[dev]'
343
+ pytest
344
+ ruff check src tests examples/basic/functions
345
+ mypy src tests
346
+ python -m build
347
+ python -m twine check dist/*
348
+ ```
349
+
350
+ ## Scope
351
+
352
+ API Builder generates application structure and validates the contract between
353
+ decorated functions. It does not diagnose infrastructure failures, determine root
354
+ cause, repair runtime systems, or create external service clients automatically.
355
+ Dependencies are named in function metadata and represented in the generated app;
356
+ application owners decide how those dependencies are implemented.
357
+
358
+ ## License
359
+
360
+ MIT. See the project metadata for the current author and package version.
@@ -0,0 +1,9 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" role="img" aria-labelledby="title desc">
2
+ <title id="title">API Builder logo</title>
3
+ <desc id="desc">A teal hexagonal API node mark with a white code chevron.</desc>
4
+ <rect width="512" height="512" rx="96" fill="#102A43"/>
5
+ <path d="M256 58 420 153v190l-164 95-164-95V153L256 58Z" fill="#16B8A6"/>
6
+ <path d="m222 181-76 75 76 75" fill="none" stroke="#102A43" stroke-linecap="round" stroke-linejoin="round" stroke-width="30"/>
7
+ <path d="m290 181 76 75-76 75" fill="none" stroke="#102A43" stroke-linecap="round" stroke-linejoin="round" stroke-width="30"/>
8
+ <path d="M271 158 241 354" fill="none" stroke="#FFFFFF" stroke-linecap="round" stroke-width="22"/>
9
+ </svg>
@@ -4,9 +4,9 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "function-api-builder"
7
- version = "0.1.0"
7
+ version = "0.1.1"
8
8
  description = "Generate complete FastAPI applications from decorated Python business functions."
9
- readme = "README.md"
9
+ readme = { file = "README.md", content-type = "text/markdown" }
10
10
  requires-python = ">=3.11"
11
11
  license = "MIT"
12
12
 
@@ -1,72 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: function-api-builder
3
- Version: 0.1.0
4
- Summary: Generate complete FastAPI applications from decorated Python business functions.
5
- Author: Sushruth Samson
6
- License-Expression: MIT
7
- Keywords: api-builder,api-generator,backend,code-generation,fastapi,pydantic
8
- Classifier: Development Status :: 3 - Alpha
9
- Classifier: Environment :: Console
10
- Classifier: Framework :: FastAPI
11
- Classifier: Intended Audience :: Developers
12
- Classifier: License :: OSI Approved :: MIT License
13
- Classifier: Operating System :: OS Independent
14
- Classifier: Programming Language :: Python :: 3
15
- Classifier: Programming Language :: Python :: 3.11
16
- Classifier: Programming Language :: Python :: 3.12
17
- Classifier: Programming Language :: Python :: 3.13
18
- Classifier: Topic :: Software Development :: Code Generators
19
- Requires-Python: >=3.11
20
- Requires-Dist: fastapi>=0.115
21
- Requires-Dist: pydantic>=2.7
22
- Requires-Dist: uvicorn>=0.30
23
- Provides-Extra: dev
24
- Requires-Dist: build>=1.2; extra == 'dev'
25
- Requires-Dist: httpx>=0.27; extra == 'dev'
26
- Requires-Dist: mypy>=1.13; extra == 'dev'
27
- Requires-Dist: pytest>=8; extra == 'dev'
28
- Requires-Dist: ruff>=0.8; extra == 'dev'
29
- Requires-Dist: twine>=6; extra == 'dev'
30
- Description-Content-Type: text/markdown
31
-
32
- # API Builder
33
-
34
- Generate a FastAPI application from decorated Python business functions.
35
-
36
- ## Install
37
-
38
- ```bash
39
- pip install function-api-builder
40
- ```
41
-
42
- ## Use
43
-
44
- Create `functions/example.py` in your project:
45
-
46
- ```python
47
- from pydantic import BaseModel
48
- from api_builder_runtime import function
49
-
50
-
51
- class Input(BaseModel):
52
- value: str
53
-
54
-
55
- class Output(BaseModel):
56
- result: str
57
-
58
-
59
- @function(service="example", step=1)
60
- def run(payload: Input, deps, context) -> Output:
61
- return Output(result=payload.value)
62
- ```
63
-
64
- Then run:
65
-
66
- ```bash
67
- api-builder
68
- ```
69
-
70
- The builder writes a complete `app/` FastAPI application with a public service route, optional local development routes, health checks, OpenAPI, and generated tests.
71
-
72
- The function signature must be `(payload, deps, context)`, with Pydantic models for the payload and return value. See `examples/basic/functions/pdf_summary.py` for a multi-step service.
@@ -1,41 +0,0 @@
1
- # API Builder
2
-
3
- Generate a FastAPI application from decorated Python business functions.
4
-
5
- ## Install
6
-
7
- ```bash
8
- pip install function-api-builder
9
- ```
10
-
11
- ## Use
12
-
13
- Create `functions/example.py` in your project:
14
-
15
- ```python
16
- from pydantic import BaseModel
17
- from api_builder_runtime import function
18
-
19
-
20
- class Input(BaseModel):
21
- value: str
22
-
23
-
24
- class Output(BaseModel):
25
- result: str
26
-
27
-
28
- @function(service="example", step=1)
29
- def run(payload: Input, deps, context) -> Output:
30
- return Output(result=payload.value)
31
- ```
32
-
33
- Then run:
34
-
35
- ```bash
36
- api-builder
37
- ```
38
-
39
- The builder writes a complete `app/` FastAPI application with a public service route, optional local development routes, health checks, OpenAPI, and generated tests.
40
-
41
- The function signature must be `(payload, deps, context)`, with Pydantic models for the payload and return value. See `examples/basic/functions/pdf_summary.py` for a multi-step service.