Skip to content

🎨 Palette: Enhance OpenAPI DX with Pydantic Schema Examples#266

Open
seonghobae wants to merge 4 commits into
developfrom
jules-1305316119032306146-8096154c
Open

🎨 Palette: Enhance OpenAPI DX with Pydantic Schema Examples#266
seonghobae wants to merge 4 commits into
developfrom
jules-1305316119032306146-8096154c

Conversation

@seonghobae

Copy link
Copy Markdown
Collaborator

What (구현 내용)

src/newsdom_api/schemas.py의 Pydantic V2 모델 선언부에 구체적인 examples 파라미터를 추가했습니다. 주요 변경 대상은 BoundingBox, CaptionNode, ImageNode, ArticleNode, PageNode, ParseQuality, ParseResponse, HealthResponse 등 코어 모델들입니다.

Why (해결하는 문제)

프론트엔드 UI가 없는 백엔드 전용 API 서비스의 특성상, 개발자 경험(DX)이 곧 사용자 경험(UX)과 직결됩니다. 기존 OpenAPI(Swagger) 문서에서는 구체적인 예시 값이 제공되지 않아, API 연동 및 테스트를 진행하는 개발자가 페이로드 형식을 직관적으로 유추하기 어려웠습니다. 이번 패치를 통해 OpenAPI 명세서 자체에서 현실적인 예시를 제공하여 개발자의 문서 이해도 및 편의성을 극대화합니다.

Impact (성능/영향)

  • Pydantic 스키마의 메타데이터만 추가되므로 기존 파싱 로직, 응답 시간, 시스템 자원 등에 성능적 영향은 전혀 없습니다.
  • 생성된 Swagger UI 페이지에서 자동으로 예제 값을 렌더링하고 Try It Out시 폼을 채워주어 개발팀의 API 연동 소요 시간이 단축될 것입니다.
  • .Jules/palette.md 파일에 Pydantic V2 Fieldexamples를 활용한 UX 개선 방법론을 추가하여 조직적 학습에 기여했습니다.

Measurement (측정/검증 방법)

  • 구문 오류가 없음을 확인하기 위해 uv run ruff formatuv run ruff check 통과 확인.
  • 변경 사항이 기존 시스템에 문제를 일으키지 않음을 검증하기 위해 전체 테스트 스위트(uv run pytest) 321개 테스트가 모두 성공함을 확인했습니다.
  • 스키마 변경 시 필수 의존성인 Pydantic 필드가 정상적으로 해석 및 초기화되는지 검증 완료.

PR created automatically by Jules for task 1305316119032306146 started by @seonghobae

Enhanced OpenAPI / Swagger UI documentation by injecting concrete `examples` into the `Field` declarations for core schema models (`BoundingBox`, `ImageNode`, `ArticleNode`, `PageNode`, `ParseQuality`, `ParseResponse`, `HealthResponse`). This acts as a direct Developer Experience (DX) micro-UX improvement for backend-only services, allowing API consumers to view and test realistic payload data natively in the generated OpenAPI specs.
Copilot AI review requested due to automatic review settings July 2, 2026 22:01
@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.

Adds concrete Pydantic v2 Field(..., examples=...) metadata to core API schemas to improve Swagger/OpenAPI documentation usability, plus a short internal “palette” note documenting the pattern.

Changes:

  • Added field-level example values to multiple Pydantic models used in API responses/structures.
  • Updated internal .Jules/palette.md with guidance on using Field(..., examples=...) for DX improvements.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/newsdom_api/schemas.py Adds examples metadata to schema fields to improve generated OpenAPI docs.
.Jules/palette.md Documents the “Field examples” approach as an internal guideline.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +13 to +18
x0: float = Field(
..., description="Leftmost X coordinate of the bounding box.", examples=[72.5]
)
y0: float = Field(
..., description="Topmost Y coordinate of the bounding box.", examples=[100.0]
)
Comment thread .Jules/palette.md Outdated
…ility

Resolved OpenAPI/Swagger UI tooling compatibility issues flagged by CI review. Refactored the raw `examples` parameter to use the standard Pydantic V2 `json_schema_extra={"examples": [...]}` format across all schema models (`BoundingBox`, `ImageNode`, `ArticleNode`, `PageNode`, `ParseQuality`, `ParseResponse`, `HealthResponse`). Also updated `.Jules/palette.md` to properly document the required array syntax.
…ility

Refactored OpenAPI example declarations in Pydantic V2 models to use `json_schema_extra={"example": <value>}` instead of `{"examples": [...]}` to resolve rendering inconsistencies in OpenAPI 3.0.x and Swagger UI tools, as raised during CI code review. Also updated Palette guidelines to explicitly document the scalar `example` syntax.
…I compatibility

Resolved a CI feedback loop where previous PRs triggered Pydantic V2 `PydanticDeprecatedSince20` warnings for using `example=` directly, or encountered Swagger UI compatibility issues for using `json_schema_extra={"examples": [...]}`. Properly refactored `src/newsdom_api/schemas.py` to use `json_schema_extra={"example": ...}` and updated Palette documentation to match, passing all 321 tests with 0 warnings.
@opencode-agent

opencode-agent Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

OpenCode Review Overview

  • Head SHA: 301aef5d1beeea6fd48e585e186f3def8261f601
  • Workflow run: 28682329638
  • Workflow attempt: 1
  • Gate result: REQUEST_CHANGES (approval step)

Pull request overview

OpenCode reviewed the current-head evidence but found unresolved reviewer or review-agent threads before approval.

Findings

1. HIGH .github/workflows/opencode-review.yml:1 - Unresolved reviewer thread blocks automated approval

  • Problem: OpenCode reached an APPROVE control result, but the approval step found unresolved, non-outdated human or review-agent thread evidence on the current pull request.
  • Root cause: Reviewer and review-agent feedback can arrive after bounded model evidence is prepared, so the approval step must re-query GitHub immediately before publishing an approval.
  • Fix: Address or resolve the listed reviewer thread(s), then re-run OpenCode on the current head.
  • Regression test: Keep the approval gate querying reviewThreads(first: 100) after model output and before create_pull_review APPROVE, including bot review agents other than OpenCode itself.

Review thread evidence

Latest unresolved reviewer thread evidence

src/newsdom_api/schemas.py line 22

  • Latest reviewer comment: @copilot-pull-request-reviewer at 2026-07-02T22:18:02Z

  • Comment URL: 🎨 Palette: Enhance OpenAPI DX with Pydantic Schema Examples #266 (comment)

  • Comment excerpt: Using JSON Schema’s 'examples' keyword at the property level is not consistently rendered by all OpenAPI/Swagger tooling (especially if the app is still emitting OpenAPI 3.0.x). If the goal is to reliably populate Swagger UI’s “Example Value”, consider switching these to an 'example=' / 'json_schema_extra={"example": ...}' style that Swagger UI consumes more consistently, or explicitly ensure the service emits OpenAPI 3.1 where 'examples' is expected to be honored.

  • Result: REQUEST_CHANGES

  • Reason: unresolved reviewer or review-agent thread(s) were present before approval.

  • Head SHA: 301aef5d1beeea6fd48e585e186f3def8261f601

  • Workflow run: 28682329638

  • Workflow attempt: 1

Changed-File Evidence Map

flowchart LR
  PR["PR changed files"] --> Evidence["OpenCode bounded evidence"]
  Evidence --> S1["Changed file (2 files)"]
  S1 --> I1["repository behavior"]
  I1 --> R1["Review risk: Changed file (2 files)"]
  R1 --> V1["required checks"]
Loading

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

OpenCode reviewed the current-head evidence but found unresolved reviewer or review-agent threads before approval.

Findings

1. HIGH .github/workflows/opencode-review.yml:1 - Unresolved reviewer thread blocks automated approval

  • Problem: OpenCode reached an APPROVE control result, but the approval step found unresolved, non-outdated human or review-agent thread evidence on the current pull request.
  • Root cause: Reviewer and review-agent feedback can arrive after bounded model evidence is prepared, so the approval step must re-query GitHub immediately before publishing an approval.
  • Fix: Address or resolve the listed reviewer thread(s), then re-run OpenCode on the current head.
  • Regression test: Keep the approval gate querying reviewThreads(first: 100) after model output and before create_pull_review APPROVE, including bot review agents other than OpenCode itself.

Review thread evidence

Latest unresolved reviewer thread evidence

src/newsdom_api/schemas.py line 22

  • Latest reviewer comment: @copilot-pull-request-reviewer at 2026-07-02T22:18:02Z

  • Comment URL: #266 (comment)

  • Comment excerpt: Using JSON Schema’s 'examples' keyword at the property level is not consistently rendered by all OpenAPI/Swagger tooling (especially if the app is still emitting OpenAPI 3.0.x). If the goal is to reliably populate Swagger UI’s “Example Value”, consider switching these to an 'example=' / 'json_schema_extra={"example": ...}' style that Swagger UI consumes more consistently, or explicitly ensure the service emits OpenAPI 3.1 where 'examples' is expected to be honored.

  • Result: REQUEST_CHANGES

  • Reason: unresolved reviewer or review-agent thread(s) were present before approval.

  • Head SHA: 301aef5d1beeea6fd48e585e186f3def8261f601

  • Workflow run: 28682329638

  • Workflow attempt: 1

Changed-File Evidence Map

flowchart LR
  PR["PR changed files"] --> Evidence["OpenCode bounded evidence"]
  Evidence --> S1["Changed file (2 files)"]
  S1 --> I1["repository behavior"]
  I1 --> R1["Review risk: Changed file (2 files)"]
  R1 --> V1["required checks"]
Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants