Skip to content

feat: スキーマを更新#10

Merged
kaitoyama merged 6 commits into
mainfrom
feat/verify-email-openapi
May 19, 2026
Merged

feat: スキーマを更新#10
kaitoyama merged 6 commits into
mainfrom
feat/verify-email-openapi

Conversation

@kaitoyama
Copy link
Copy Markdown
Collaborator

@kaitoyama kaitoyama commented Mar 22, 2026

  • verify-emailを追加
  • 管理者追加をいったん削除(追加可能権限とか決まっていないので)
  • webhookのレスポンスタイプなどを整理

Summary by CodeRabbit

  • 新機能

    • メール検証の送信・確認フロー用の公開APIを追加(送信、確認トークン受け取り)。
    • CSRFトークン取得用APIを追加。
  • 改善

    • 顧客作成・更新および請求作成にCSRFヘッダ+クッキー認証を導入。
    • 請求・決済関連の数値/タイムスタンプ精度を拡張(int64相当)。
    • 請求作成APIの応答形式を更新。
  • 削除

    • 管理者向けの作成・削除APIを廃止。
  • 変更

    • 決済Webhook受信仕様を厳格化(ボディ必須・受信フォーマット変更・クライアントエラーを400へ)。
    • 顧客/請求ルートのエラー応答を拡張(400/401/403 など)。

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 22, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

OpenAPI定義と生成サーバーコードを同期。メール確認フロー(POST /verify-emailGET/POST /verify-email/confirm)とCSRFヘッダ+クッキー認証(GET /csrf追加、cookieAuth/X-CSRF-Token導入)が追加され、管理者の書き込みエンドポイントが削除され、請求・Webhookスキーマや複数数値フィールドがint64へ更新されました。

Changes

Cohort / File(s) Summary
API Specification
openapi.yaml
追加: POST /verify-email, GET /verify-email/confirm, POST /verify-email/confirm, GET /csrftags: Auth。導入: components.parameters.CsrfToken (X-CSRF-Token)、components.parameters.VerifyEmailRedirectcomponents.securitySchemes.cookieAuthGET /customercookieAuthPOST /customer/PATCH /customer/POST /invoicecookieAuthX-CSRF-Tokenを追加。POST /invoiceのレスポンスをCreateInvoiceResponseへ変更。POST /webhook/invoice-paidrequestBodyを必須化・スキーマをStripeEventへ変更・クライアントエラーを403400へ変更。削除: POST /admin, DELETE /adminInvoice等の数値フィールドにformat: int64を追加。
Generated Server Code
server/gen.go
oapi-codegenで再生成(v2.5.0)。新型/別名追加: CreateInvoiceResponse, StripeEvent, VerifyEmailRequest, VerifyEmailStartResponse, CsrfToken, VerifyEmailRedirect(RelativeRedirectPath)など。数値型を*int*int64へ変更(Invoice、GetCheckoutSessionsResponse等)。削除: DeleteAdminParams/ServerInterface.DeleteAdminおよびルート登録。追加: ServerInterface.GetCsrfPostVerifyEmailGetVerifyEmailConfirmPostVerifyEmailConfirmPostCustomer/PatchCustomer/PostInvoice*Params型を導入し、ラッパーでCookieAuthScopesをコンテキストに設定、X-CSRF-Token必須検証(欠如/不正で400応答)。Webhookのリクエストボディ型をInvoiceStripeEventへ変更。埋め込みswaggerSpec更新。

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive PRタイトルが日本語で「スキーマを更新」と記載されていますが、実装内容は認証エンドポイントの追加、CSRF保護の導入、webhook契約の変更など多岐にわたる重要な変更が含まれており、より具体的な説明が必要です。 タイトルを「feat: メール検証エンドポイント追加とCSRF保護の導入」など、主要な変更を明確に反映した内容に修正することを推奨します。
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/verify-email-openapi

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
openapi.yaml (2)

9-37: オペレーションに description フィールドがありません。

Spectral の静的解析で指摘されている通り、POST /verify-emaildescription フィールドがありません。summary は短い概要用で、description はより詳細な説明(認証フロー、トークンの有効期限、リダイレクトパスの検証ルールなど)を記載するために使用されます。

📝 descriptionの追加例
   /verify-email:
     post:
       summary: isct メールアドレスを検証して JWT を発行
+      description: |
+        isct ドメインのメールアドレスを検証し、認証用の JWT トークンを発行します。
+        redirect パラメータで指定されたパスはバリデーション後にレスポンスに含まれます。
       tags:
         - Auth
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@openapi.yaml` around lines 9 - 37, The OpenAPI operation POST /verify-email
(operationId: postVerifyEmail) is missing a descriptive description field; add a
"description" for this operation that expands on the summary by explaining the
verification flow, expected request/response behavior (e.g., token issuance and
expiry), validation rules for the optional "redirect" query parameter, and any
side effects or error conditions so Spectral validation passes and consumers
understand usage.

504-507: StripeEvent スキーマの型定義が緩すぎる可能性があります。

additionalProperties: true のみでは、Webhook ペイロードの構造が不明確です。Stripe Event には idtypedata などの必須フィールドがあります。

Stripe 側での署名検証(Stripe-Signature ヘッダー)が行われることを考慮すると、現状でも機能上は問題ありませんが、API ドキュメントとしての明示性やコード生成時の型安全性が低下します。

💡 最小限の型定義を追加する例
     StripeEvent:
       description: Generic Stripe event payload
       type: object
+      properties:
+        id:
+          type: string
+          description: Event ID
+        type:
+          type: string
+          description: Event type (e.g., invoice.paid)
+        data:
+          type: object
+          additionalProperties: true
       additionalProperties: true
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@openapi.yaml` around lines 504 - 507, The StripeEvent schema is too
permissive; update the StripeEvent object in openapi.yaml to explicitly declare
its core fields (e.g., add properties id: string, type: string, created: integer
or string(date-time), api_version: string (optional), and data: object with a
nested object or object.value placeholder) and mark the required fields (at
least id and type and data), while you may keep additionalProperties: true for
forward compatibility; modify the StripeEvent definition (symbol: StripeEvent)
to include these properties and required array to improve documentation and
generated type safety.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@openapi.yaml`:
- Around line 9-37: The OpenAPI operation POST /verify-email (operationId:
postVerifyEmail) is missing a descriptive description field; add a "description"
for this operation that expands on the summary by explaining the verification
flow, expected request/response behavior (e.g., token issuance and expiry),
validation rules for the optional "redirect" query parameter, and any side
effects or error conditions so Spectral validation passes and consumers
understand usage.
- Around line 504-507: The StripeEvent schema is too permissive; update the
StripeEvent object in openapi.yaml to explicitly declare its core fields (e.g.,
add properties id: string, type: string, created: integer or string(date-time),
api_version: string (optional), and data: object with a nested object or
object.value placeholder) and mark the required fields (at least id and type and
data), while you may keep additionalProperties: true for forward compatibility;
modify the StripeEvent definition (symbol: StripeEvent) to include these
properties and required array to improve documentation and generated type
safety.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 641e2e2f-efff-436a-aa59-3039f83386c1

📥 Commits

Reviewing files that changed from the base of the PR and between adaf6a7 and 8cae07b.

📒 Files selected for processing (2)
  • openapi.yaml
  • server/gen.go

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
openapi.yaml (1)

557-560: StripeEvent スキーマは汎用的な定義です。

Stripe のイベントペイロードは多様なため、additionalProperties: true の汎用オブジェクトとして定義するのは実用的なアプローチです。ただし、typeid などの共通フィールドを明示的に定義することで、ドキュメントとしての価値が向上する可能性があります。

💡 オプション: 共通フィールドの明示的定義
     StripeEvent:
       description: Generic Stripe event payload
       type: object
       additionalProperties: true
+      properties:
+        id:
+          type: string
+          description: Stripe event ID
+        type:
+          type: string
+          description: Event type (e.g., invoice.paid)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@openapi.yaml` around lines 557 - 560, The StripeEvent schema is currently a
catch-all (additionalProperties: true); improve documentation and validation by
explicitly declaring common Stripe event fields (e.g., properties: { id: { type:
string }, type: { type: string }, api_version: { type: string }, created: {
type: integer }, livemode: { type: boolean }, data: { type: object } }) and
marking them as optional/required as appropriate while keeping
additionalProperties: true; update the StripeEvent object definition to include
these named properties so consumers see common fields yet retain flexibility.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@openapi.yaml`:
- Line 358: 現在の pattern 値 "(?i)^[^@\s]+@isct\.ac\.jp$" は PCRE のインラインフラグ (?i)
を含んでおり OpenAPI (ECMA-262) で無効です。pattern
プロパティを編集し、インラインフラグを取り除いて代わりに大文字小文字を許容する文字クラスを使う(例:
^[^@\s]+@[Ii][Ss][Cc][Tt]\.ac\.jp$)か、あるいはスキーマレベルで JSON Schema の patternFlags
を使する方針に切り替えて修正してください(修正箇所: the pattern value currently set to
(?i)^[^@\s]+@isct\.ac\.jp$)。
- Around line 9-69: Add a detailed description field for each operation to
satisfy Spectral and provide clearer docs: for operationId postVerifyEmail (POST
/verify-email) add a description explaining that this endpoint accepts a
VerifyEmailRequest JSON body, sends a one-time verification email to the
provided address, optionally uses the redirect query param to build the
verification link, and returns 202 when the email dispatch is accepted; for
operationId getVerifyEmailConfirm (GET /verify-email/confirm) add a description
stating it validates the one-time token query param, completes login or account
verification and responds with a 303 redirect on success (or 400/401/500 as
documented); for operationId getCsrf (GET /csrf) add a description that the
endpoint issues a CSRF token cookie (no response body) and returns 204. Ensure
each description is placed under the operation's description field in the
OpenAPI spec.
- Around line 342-346: The OpenAPI spec defines a security scheme cookieAuth
(securitySchemes.cookieAuth, name: checkin_session) but it is not applied
anywhere; either remove the unused cookieAuth entry or apply it to relevant
operations/global security. To fix: if endpoints require the cookie session, add
a security requirement referencing cookieAuth to those operation objects or to
the global security root; otherwise delete the cookieAuth definition from
components.securitySchemes to avoid dead spec entries. Ensure you reference the
exact scheme name "cookieAuth" and cookie name "checkin_session" when making the
change.

---

Nitpick comments:
In `@openapi.yaml`:
- Around line 557-560: The StripeEvent schema is currently a catch-all
(additionalProperties: true); improve documentation and validation by explicitly
declaring common Stripe event fields (e.g., properties: { id: { type: string },
type: { type: string }, api_version: { type: string }, created: { type: integer
}, livemode: { type: boolean }, data: { type: object } }) and marking them as
optional/required as appropriate while keeping additionalProperties: true;
update the StripeEvent object definition to include these named properties so
consumers see common fields yet retain flexibility.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f2e38c82-a357-4f90-b372-b96ccea0fcee

📥 Commits

Reviewing files that changed from the base of the PR and between 8cae07b and 40b4e4c.

📒 Files selected for processing (2)
  • openapi.yaml
  • server/gen.go

Comment thread openapi.yaml
Comment on lines +9 to +69
/verify-email:
post:
summary: isct メールアドレスの確認メールを送信
tags:
- Auth
operationId: postVerifyEmail
parameters:
- name: redirect
in: query
description: 検証後に遷移する相対パス
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/VerifyEmailRequest'
responses:
'202':
description: Accepted
content:
application/json:
schema:
$ref: '#/components/schemas/VerifyEmailStartResponse'
'400':
$ref: '#/components/responses/BadRequest'
'500':
$ref: '#/components/responses/InternalServerError'
/verify-email/confirm:
get:
summary: メール確認トークンを検証してログインを完了
tags:
- Auth
operationId: getVerifyEmailConfirm
parameters:
- name: token
in: query
required: true
description: 確認メールに含まれるワンタイムトークン
schema:
type: string
minLength: 32
responses:
'303':
description: See Other
'400':
$ref: '#/components/responses/BadRequest'
'401':
description: Unauthorized
'500':
$ref: '#/components/responses/InternalServerError'
/csrf:
get:
summary: CSRF トークン用 cookie を発行
tags:
- Auth
operationId: getCsrf
responses:
'204':
description: No Content
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

description フィールドが不足しています。

Spectral のパイプライン警告によると、POST /verify-emailGET /verify-email/confirmGET /csrf の各操作に description フィールドがありません。summary は短い概要ですが、description でより詳細な説明を提供することが推奨されています。

📝 description 追加の例
   /verify-email:
     post:
       summary: isct メールアドレスの確認メールを送信
+      description: |
+        指定されたメールアドレスに確認メールを送信します。
+        メールには確認用のワンタイムトークンが含まれます。
       tags:
         - Auth
🧰 Tools
🪛 GitHub Actions: Run Spectral on Pull Requests

[warning] 10-10: Spectral (operation-description): Operation "description" must be present and non-empty string. paths./verify-email.post (https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#operation-description)


[warning] 39-39: Spectral (operation-description): Operation "description" must be present and non-empty string. paths./verify-email/confirm.get (https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#operation-description)


[warning] 62-62: Spectral (operation-description): Operation "description" must be present and non-empty string. paths./csrf.get (https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#operation-description)

🪛 GitHub Check: Run Spectral

[warning] 62-62:
operation-description Operation "description" must be present and non-empty string. paths./csrf.get


[warning] 39-39:
operation-description Operation "description" must be present and non-empty string. paths./verify-email/confirm.get


[warning] 10-10:
operation-description Operation "description" must be present and non-empty string. paths./verify-email.post

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@openapi.yaml` around lines 9 - 69, Add a detailed description field for each
operation to satisfy Spectral and provide clearer docs: for operationId
postVerifyEmail (POST /verify-email) add a description explaining that this
endpoint accepts a VerifyEmailRequest JSON body, sends a one-time verification
email to the provided address, optionally uses the redirect query param to build
the verification link, and returns 202 when the email dispatch is accepted; for
operationId getVerifyEmailConfirm (GET /verify-email/confirm) add a description
stating it validates the one-time token query param, completes login or account
verification and responds with a 303 redirect on success (or 400/401/500 as
documented); for operationId getCsrf (GET /csrf) add a description that the
endpoint issues a CSRF token cookie (no response body) and returns 204. Ensure
each description is placed under the operation's description field in the
OpenAPI spec.

Comment thread openapi.yaml Outdated
Comment thread openapi.yaml Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
openapi.yaml (1)

106-123: ⚠️ Potential issue | 🟠 Major

X-CSRF-Token 必須化に対する 400 が抜けています。

生成された Echo wrapper は header 不在/不正で即 400 を返しますが、この 3 operation の responses には 400 がありません。契約と生成サーバーの挙動がずれるので、BadRequest を追加したいです。

Also applies to: 129-146, 153-170

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@openapi.yaml` around lines 106 - 123, The OpenAPI operations that include the
CsrfToken parameter (the blocks referencing components/parameters/CsrfToken and
returning 201/500) are missing a 400 response; add a '400' response (preferably
by referencing an existing components/responses/BadRequest or by defining a
BadRequest response) to each of those operations so the spec matches the
generated Echo wrapper which returns 400 for missing/invalid X-CSRF-Token;
update the three operation response sections (the ones shown and the other two
at the noted ranges) to include '400': $ref:
'#/components/responses/BadRequest'.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@openapi.yaml`:
- Around line 61-69: The /csrf GET operation (operationId: getCsrf) currently
returns a 204 with no Set-Cookie header, cookie name, or instructions for the
double-submit flow; update the OpenAPI spec to (1) document the Set-Cookie
response header including the cookie name (e.g., "CsrfToken"), attributes
(HttpOnly=false if client-readable, Secure, SameSite), and the cookie value
source, (2) include a response header definition for X-CSRF-Token (or describe
that the client must read the CsrfToken cookie and copy it to X-CSRF-Token) with
a schema string and example, and (3) add a short description in the operation
describing the double-submit sequence (server sets CsrfToken cookie, client
reads cookie and sends its value in X-CSRF-Token on state-changing requests) so
clients can implement the flow; apply the same changes to the other occurrence
referenced (lines 298-305 / corresponding operation).
- Around line 15-20: The query parameter named "redirect" currently only has
type:string and must be constrained to accept only relative paths like
VerifyEmailStartResponse.redirect; update the parameter definition for
"redirect" to use the same schema/pattern (and/or enum/format) as
VerifyEmailStartResponse.redirect so absolute URLs and protocol-relative URLs
are rejected, ensuring the request-side contract matches the response-side
constraint.

---

Outside diff comments:
In `@openapi.yaml`:
- Around line 106-123: The OpenAPI operations that include the CsrfToken
parameter (the blocks referencing components/parameters/CsrfToken and returning
201/500) are missing a 400 response; add a '400' response (preferably by
referencing an existing components/responses/BadRequest or by defining a
BadRequest response) to each of those operations so the spec matches the
generated Echo wrapper which returns 400 for missing/invalid X-CSRF-Token;
update the three operation response sections (the ones shown and the other two
at the noted ranges) to include '400': $ref:
'#/components/responses/BadRequest'.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: dcf276e2-3e6b-4d26-9ea4-5c8c14964b79

📥 Commits

Reviewing files that changed from the base of the PR and between 40b4e4c and 5b0a791.

📒 Files selected for processing (2)
  • openapi.yaml
  • server/gen.go

Comment thread openapi.yaml Outdated
Comment thread openapi.yaml
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@openapi.yaml`:
- Around line 80-81: The OpenAPI spec adds authentication (security: cookieAuth)
to GET /customer and requires X-CSRF-Token on three write endpoints but omits
failure responses; update the relevant operation objects (e.g., the GET
/customer operation with security: cookieAuth and each write operation that
checks X-CSRF-Token) to include appropriate error responses: add 401 and/or 403
responses for authentication/authorization failures matching implementation
behavior, and add 400 responses for missing/invalid CSRF tokens on the write
endpoints; ensure the response objects include a brief description and reference
any existing error schema used elsewhere so clients can see failure conditions.
- Around line 49-50: The 303 response for GET /verify-email/confirm lacks the
redirect Location and the Set-Cookie header that issues the checkin_csrf cookie
(required by the CsrfToken parameter); update the '303' response object to
include response headers: a Location header (string, example value pointing to
the redirect target used by your flow) and a Set-Cookie header (string,
documenting issuance of the checkin_csrf cookie including attributes like
HttpOnly, Secure, Path, SameSite and an example cookie value), and ensure the
description mentions the redirect plus cookie issuance so consumers implementing
the browser flow can rely on the redirect URL and the checkin_csrf cookie being
set.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: af7641d2-c6e5-463e-abed-15261f4281b7

📥 Commits

Reviewing files that changed from the base of the PR and between 5b0a791 and 57f9d9b.

📒 Files selected for processing (2)
  • openapi.yaml
  • server/gen.go

Comment thread openapi.yaml
Comment thread openapi.yaml Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
openapi.yaml (2)

111-121: /csrfCache-Control: no-store に揃えたいです。

確認フロー側は no-store を返しているのに、CSRF cookie を配る GET /csrf だけ cache 抑止がありません。token 発行 endpoint の応答は stale token の再利用余地を減らすためにも non-cacheable にしておく方が安全です。

📦 変更案
       responses:
         '204':
           description: No Content
           headers:
+            Cache-Control:
+              description: ブラウザや中継に保存させない
+              schema:
+                type: string
+                example: no-store
             Set-Cookie:
               description: >
                 `__Host-checkin_csrf` cookie を発行する。state-changing request では、この cookie の値を
                 `X-CSRF-Token` header にそのままコピーして送る。
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@openapi.yaml` around lines 111 - 121, The /csrf response (operation for path
"/csrf", response '204' that sets the Set-Cookie header) is missing a
Cache-Control header; add a non-cacheable header entry under
responses.'204'.headers named "Cache-Control" with a description and schema {
type: string } and example "no-store" so the OpenAPI explicitly documents that
this endpoint must return Cache-Control: no-store to prevent token caching.

267-271: invoice.paid 用 endpoint に対して payload schema が広すぎます。

StripeEvent が自由オブジェクトのままなので、POST /webhook/invoice-paid でも type == invoice.paiddata.object の存在を仕様から保証できません。これだと生成型も map[string]interface{} になり、この endpoint が前提にしている最小 shape を client / test 側で検証しづらくなります。

🧩 変更案
     StripeEvent:
-      description: Generic Stripe event payload
+      description: Stripe invoice.paid event payload
       type: object
+      required:
+        - id
+        - type
+        - data
+      properties:
+        id:
+          type: string
+        type:
+          type: string
+          enum:
+            - invoice.paid
+        data:
+          type: object
+          required:
+            - object
+          properties:
+            object:
+              type: object
+              additionalProperties: true
       additionalProperties: true

Also applies to: 671-674

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@openapi.yaml` around lines 267 - 271, The POST /webhook/invoice-paid endpoint
currently references the overly-broad components/schemas/StripeEvent; narrow the
request schema to a specific invoice-paid event shape by adding (or referencing)
a new schema like InvoicePaidEvent that requires "type": "invoice.paid" and a
non-empty "data.object" with the minimal invoice fields your handler needs
(e.g., id, customer, amount_paid, status); update the openapi.yaml entry for the
endpoint to use this new InvoicePaidEvent schema instead of StripeEvent so
generated clients/tests get a concrete typed structure rather than
map[string]interface{}.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@openapi.yaml`:
- Around line 442-446: The OpenAPI spec defines securitySchemes.cookieAuth using
the __Host-checkin_session cookie but does not declare HTTPS-only transport in
servers; update the spec so cookieAuth's intended secure transport is explicit
by adding/ensuring at least one HTTPS server entry under servers (and, if
retaining an HTTP server, separate it clearly as a development server), and
annotate or document the securitySchemes.cookieAuth (and the
__Host-checkin_session name) to indicate it requires secure (Secure, SameSite,
Host-only) cookie semantics; modify the top-level servers list and the
securitySchemes.cookieAuth description to reflect this requirement.

---

Nitpick comments:
In `@openapi.yaml`:
- Around line 111-121: The /csrf response (operation for path "/csrf", response
'204' that sets the Set-Cookie header) is missing a Cache-Control header; add a
non-cacheable header entry under responses.'204'.headers named "Cache-Control"
with a description and schema { type: string } and example "no-store" so the
OpenAPI explicitly documents that this endpoint must return Cache-Control:
no-store to prevent token caching.
- Around line 267-271: The POST /webhook/invoice-paid endpoint currently
references the overly-broad components/schemas/StripeEvent; narrow the request
schema to a specific invoice-paid event shape by adding (or referencing) a new
schema like InvoicePaidEvent that requires "type": "invoice.paid" and a
non-empty "data.object" with the minimal invoice fields your handler needs
(e.g., id, customer, amount_paid, status); update the openapi.yaml entry for the
endpoint to use this new InvoicePaidEvent schema instead of StripeEvent so
generated clients/tests get a concrete typed structure rather than
map[string]interface{}.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8bfe3798-40db-472c-9a3b-816294b3502d

📥 Commits

Reviewing files that changed from the base of the PR and between 57f9d9b and 8f0bd1b.

📒 Files selected for processing (2)
  • openapi.yaml
  • server/gen.go

Comment thread openapi.yaml Outdated
Comment on lines +442 to +446
securitySchemes:
cookieAuth:
type: apiKey
in: cookie
name: __Host-checkin_session
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

cookieAuth の transport 条件を仕様に出しておきたいです。

__Host-checkin_session を前提にしたのに、この spec には HTTPS-only な servers: がなく、契約上は平文の base URL でも成立して見えます。secure cookie を本当に前提にするなら、少なくとも HTTPS の server entry を明示して、HTTP を残す場合も開発用と分けておいた方が安全です。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@openapi.yaml` around lines 442 - 446, The OpenAPI spec defines
securitySchemes.cookieAuth using the __Host-checkin_session cookie but does not
declare HTTPS-only transport in servers; update the spec so cookieAuth's
intended secure transport is explicit by adding/ensuring at least one HTTPS
server entry under servers (and, if retaining an HTTP server, separate it
clearly as a development server), and annotate or document the
securitySchemes.cookieAuth (and the __Host-checkin_session name) to indicate it
requires secure (Secure, SameSite, Host-only) cookie semantics; modify the
top-level servers list and the securitySchemes.cookieAuth description to reflect
this requirement.

@kaitoyama kaitoyama requested a review from reiroop March 22, 2026 12:07
@kaitoyama kaitoyama merged commit 913b903 into main May 19, 2026
2 checks passed
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.

1 participant