Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ demo-swagger: ensure-hatch
@rm -rf $(SWAGGER_PREVIEW_DIR)
@rm -rf $(SPEC_PREVIEW_DIR)
@mkdir -p $(SWAGGER_PREVIEW_DIR) $(SPEC_PREVIEW_DIR) docs/assets
@$(HATCH) run python demo/run_hello_example.py --output-dir demo/.preview
@$(HATCH) run python demo/run_webhook_receiver_example.py --output-dir demo/.preview
@PLAYWRIGHT_BROWSERS_PATH="$(PLAYWRIGHT_BROWSERS_PATH)" npx -y playwright@$(PLAYWRIGHT_VERSION) install chromium > /dev/null
@python3 -m http.server $(SPEC_PREVIEW_PORT) --directory $(SPEC_PREVIEW_DIR) > /tmp/openapi-spec-preview.log 2>&1 & \
SPEC_PID=$$!; \
Expand Down
9 changes: 4 additions & 5 deletions PRD.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,10 @@ Run `func start`, then open `http://localhost:7071/api/docs` for Swagger UI.

| Role | Path | Pattern |
|---|---|---|
| Representative | `examples/hello` | Minimal HTTP trigger with OpenAPI and Swagger UI |
| Representative | `examples/hello_openapi` | Extended OpenAPI metadata example |
| Complex | `examples/todo_crud` | CRUD app with Pydantic models and generated spec |
| Complex | `examples/todo_crud_api` | Full CRUD API with validation integration |
| Integration | `examples/with_validation` | Combined `@openapi` and `@validate_http` |
| Representative | `examples/webhook_receiver` | Webhook intake with HMAC-SHA256 verification |
| Complex | `examples/report_jobs` | Async report generation with Bearer auth |
| Integration | `examples/notification_request` | Combined `@openapi` and `@validate_http` |
| Bridge | `examples/partner_import_bridge` | Bridge pattern with `register_openapi_metadata()` |

All examples are smoke-tested in CI. New features must ship with a corresponding example
or an extension to an existing one.
6 changes: 3 additions & 3 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func start

## Demo

代表的な `hello` サンプルは、このライブラリを導入したときの結果全体を示します。
代表的な `webhook_receiver` サンプルは、このライブラリを導入したときの結果全体を示します。

- Azure Functions v2 の HTTP ハンドラーに `@openapi` を付与します。
- パッケージがそのルートに対する実際の OpenAPI ドキュメントを生成します。
Expand All @@ -145,13 +145,13 @@ func start

生成された OpenAPI ファイルは、同じサンプル実行から静的プレビューとして取得されています。そのため、この README には代表的な関数が実際に生成したドキュメントが表示されます。

![OpenAPI spec preview](docs/assets/hello_openapi_spec_preview.png)
![OpenAPI spec preview](docs/assets/webhook_receiver_openapi_spec_preview.png)

### Swagger UI Result

以下の Web プレビューも同じ代表サンプルから生成されており、そのフローで作られた Swagger UI ページを自動的にレンダリングして取得したものです。

![OpenAPI Swagger UI preview](docs/assets/hello_openapi_swagger_ui_preview.png)
![OpenAPI Swagger UI preview](docs/assets/webhook_receiver_swagger_ui_preview.png)

## Documentation

Expand Down
6 changes: 3 additions & 3 deletions README.ko.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func start

## Demo

대표 `hello` 예제는 이 라이브러리를 도입했을 때의 전체 결과를 보여줍니다.
대표 `webhook_receiver` 예제는 이 라이브러리를 도입했을 때의 전체 결과를 보여줍니다.

- Azure Functions v2 HTTP 핸들러에 `@openapi`를 추가합니다.
- 패키지가 해당 라우트에 대한 실제 OpenAPI 문서를 생성합니다.
Expand All @@ -145,13 +145,13 @@ func start

생성된 OpenAPI 파일은 같은 예제 실행 결과에서 정적 미리보기로 캡처되었습니다. 따라서 이 README에는 대표 함수가 실제로 생성한 문서가 그대로 표시됩니다.

![OpenAPI spec preview](docs/assets/hello_openapi_spec_preview.png)
![OpenAPI spec preview](docs/assets/webhook_receiver_openapi_spec_preview.png)

### Swagger UI Result

아래 웹 미리보기 역시 같은 대표 예제에서 생성되었으며, 해당 예제 흐름이 만든 Swagger UI 페이지를 자동으로 렌더링해 캡처한 결과입니다.

![OpenAPI Swagger UI preview](docs/assets/hello_openapi_swagger_ui_preview.png)
![OpenAPI Swagger UI preview](docs/assets/webhook_receiver_swagger_ui_preview.png)

## Documentation

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ The `/api/openapi.json`, `/api/openapi.yaml`, and `/api/docs` endpoints are also

## Demo

The representative `hello` example shows the full outcome of adopting this library:
The representative `webhook_receiver` example shows the full outcome of adopting this library:

- You annotate an Azure Functions v2 HTTP handler with `@openapi`.
- The package generates a real OpenAPI document for that route.
Expand All @@ -284,13 +284,13 @@ The representative `hello` example shows the full outcome of adopting this libra

The generated OpenAPI file is captured as a static preview from the same example run, so the README shows the actual document produced by the representative function.

![OpenAPI spec preview](docs/assets/hello_openapi_spec_preview.png)
![OpenAPI spec preview](docs/assets/webhook_receiver_openapi_spec_preview.png)

### Swagger UI Result

The web preview below is generated from the same representative example and captured automatically from the rendered Swagger UI page produced by that example flow.

![OpenAPI Swagger UI preview](docs/assets/hello_openapi_swagger_ui_preview.png)
![OpenAPI Swagger UI preview](docs/assets/webhook_receiver_swagger_ui_preview.png)

## When to use

Expand Down
6 changes: 3 additions & 3 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func start

## Demo

代表性的 `hello` 示例展示了采用该库后的完整效果:
代表性的 `webhook_receiver` 示例展示了采用该库后的完整效果:

- 你为 Azure Functions v2 的 HTTP 处理函数添加 `@openapi`。
- 该包会为该路由生成真实的 OpenAPI 文档。
Expand All @@ -145,13 +145,13 @@ func start

生成的 OpenAPI 文件来自同一次示例运行,并被捕获为静态预览。因此,此 README 展示的就是代表性函数实际生成的文档。

![OpenAPI spec preview](docs/assets/hello_openapi_spec_preview.png)
![OpenAPI spec preview](docs/assets/webhook_receiver_openapi_spec_preview.png)

### Swagger UI Result

下面的网页预览也来自同一个代表性示例,并由该示例流程生成的 Swagger UI 页面自动渲染和截图得到。

![OpenAPI Swagger UI preview](docs/assets/hello_openapi_swagger_ui_preview.png)
![OpenAPI Swagger UI preview](docs/assets/webhook_receiver_swagger_ui_preview.png)

## Documentation

Expand Down
2 changes: 1 addition & 1 deletion demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

The README demo assets are generated from code:

- `run_hello_example.py` executes the representative `hello` example flow and generates the OpenAPI and Swagger UI artifacts used by the README.
- `run_webhook_receiver_example.py` executes the representative `webhook_receiver` example flow and generates the OpenAPI and Swagger UI artifacts used by the README.
- `make demo` regenerates the generated spec preview image and the Swagger UI preview image.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def _build_spec_preview_html(openapi_yaml: str) -> str:
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Hello OpenAPI Spec Preview</title>
<title>Webhook Receiver OpenAPI Spec Preview</title>
<style>
:root {{
color-scheme: dark;
Expand Down Expand Up @@ -103,7 +103,7 @@ def _build_spec_preview_html(openapi_yaml: str) -> str:
<main>
<section class="panel">
<div class="panel-header">
<span class="eyebrow">Generated from examples/hello</span>
<span class="eyebrow">Generated from examples/webhook_receiver</span>
<h1>OpenAPI Output</h1>
<p>
The representative example produces this OpenAPI document before
Expand Down Expand Up @@ -162,7 +162,7 @@ def _build_preview(spec: dict[str, object]) -> dict[str, object]:

def main() -> None:
parser = argparse.ArgumentParser(
description="Run the representative hello example and generate demo assets."
description="Run the representative webhook_receiver example and generate demo assets."
)
parser.add_argument("--output-dir", type=Path, required=True)
args = parser.parse_args()
Expand All @@ -176,19 +176,19 @@ def main() -> None:
with decorator_module._registry_lock:
decorator_module._openapi_registry.clear()

module = import_module("examples.hello.function_app")
module = import_module("examples.webhook_receiver.function_app")
reload(module)

openapi_yaml = get_openapi_yaml(
title="Hello OpenAPI Demo",
title="Webhook Receiver OpenAPI Demo",
version="1.0.0",
)
openapi_json = get_openapi_json(
title="Hello OpenAPI Demo",
title="Webhook Receiver OpenAPI Demo",
version="1.0.0",
)
swagger_response = render_swagger_ui(
title="Hello OpenAPI Demo",
title="Webhook Receiver OpenAPI Demo",
openapi_url="/openapi.json",
)

Expand All @@ -211,7 +211,7 @@ def main() -> None:
default_flow_style=False,
).strip()

print("Representative example: examples/hello/function_app.py")
print("Representative example: examples/webhook_receiver/function_app.py")
print(f"Generated: {output_dir / 'openapi.yaml'}")
print(f"Generated: {spec_dir / 'index.html'}")
print(f"Generated: {swagger_dir / 'index.html'}")
Expand Down
6 changes: 3 additions & 3 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ make precommit
Examples in `examples/` are part of the supported API experience. They must remain
functional and have smoke test coverage.

- Keep one representative example for the minimal OpenAPI workflow (`hello`).
- Keep one complex example for multi-endpoint behavior (`todo_crud`).
- Keep one integration example (`with_validation`).
- Keep one representative example for the minimal OpenAPI workflow (`webhook_receiver`).
- Keep one complex example for multi-endpoint behavior (`report_jobs`).
- Keep one integration example (`notification_request`).
- Add or update smoke tests whenever an example changes.

## Reporting Issues
Expand Down
Loading
Loading