Skip to content

Add a Qonto template generated from Qonto's OpenAPI documents - #375

Merged
tnkuehne merged 5 commits into
mainfrom
feat/qonto-template
Nov 24, 2026
Merged

tnkuehne merged 5 commits into
mainfrom
feat/qonto-template

Conversation

@tnkuehne

@tnkuehne tnkuehne commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Change

A Qonto template.

  • 185 methods for Qonto's Business API:
    • business accounts, statements, transactions, labels and attachments
    • SEPA, internal and international transfers, beneficiaries and payee verification
    • transfer and card requests, SEPA Direct Debit, cards
    • clients, products, client and supplier invoices, quotes, credit notes, reminders
    • payment links, terminals, memberships, teams, insurance contracts, webhook subscriptions
  • Not offered:
    • trusting beneficiaries and approving or declining requests, so Qonto's own approvals stay with the people Qonto names
    • Embed partner, Sandbox and deprecated operations

Connection.

  • Each organization connects through its own Qonto app for the "Automate your business operations" use case, with QONTO_CLIENT_ID and QONTO_CLIENT_SECRET. Qonto requires no review for that use case.
  • Better Auth's generic OAuth plugin with PKCE. The client's credentials go in the form body, because Qonto rejects Basic authentication.
  • The member's identity comes from GET /v2/membership.

Qonto's own approval (SCA).

  • When Qonto answers 428 with an SCA session, the method returns the question approveInQonto, with the session and idempotency key in requestState.
  • When the user confirms, the method checks the session:
    • waiting asks again
    • deny returns rejected_in_qonto
    • allow repeats the first request with X-Qonto-Sca-Session-Token and the same idempotency key
  • Every change carries X-Qonto-Idempotency-Key. Widefleet's question keeps the key in requestState, so an answer repeated after a lost response pays once.
  • An explicit decline stands even after the user's level stops asking.
  • revokeAccess removes the saved connection once Qonto confirms.

Generator.

  • Qonto publishes no single description: each reference page holds one complete OpenAPI 3.1 document. A rules' download can now return parts, which the generator joins. Parts that describe a shared component, path or document field differently stop it.
  • OpenAPI 3.1 type lists such as ["string", "null"], a bare null type and const are read as 3.0 schemas.
  • allOf parts that only annotate, such as with an example, no longer add & JsonValue.
  • Enums that list null no longer get a second | null.
  • A form that carries files is sent as multipart when an operation also takes a plain form.
  • Joined parts compare by keys and values, whatever order they list keys in.
  • The other OpenAPI templates are 3.0 descriptions without such parts, so their generated files are unchanged.

Screenshots

The template's connection page, in the WHOOP and Strava layout:

Setup required Not connected
Connected Connected, 390 px

The favicon is Qonto's mark from qonto.com, beside other templates' icons:

Not shown: the dark color scheme of the favicon.

Tests

  • Template tests:
    • connection with the organization's app
    • user and issuer isolation
    • transactions, client filters and file downloads
    • the full SCA flow: Widefleet approval, 428, waiting, approval, replay with the same key and no second transfer, decline, refusal
    • trusted beneficiaries without SCA, each payment with its own key
    • one key through Widefleet's question, and a decline after the level changed
    • multipart parts for attachments and supplier invoices
    • Qonto's error shape, payment policy, 428 without a session, rate limits, refresh, reconnect and revokeAccess
  • Generator tests for joining parts and OpenAPI 3.1 schemas.
  • Ran pnpm check, the generator tests, the template tests and the control-plane template tests.
  • Not yet run against Qonto's live API.

RetriggerView in GreptileConfidence Score: 4/5

Hold the merge until revocation removes the link for the same Qonto account whose token it used.

Findings

  1. P1 Revocation can disconnect another account ▶
  2. P2 File rules still send text ▶

Summary

This PR adds a Qonto template with 185 typed methods, per-user OAuth connections, and a payment flow that can pause for approval in Widefleet and Qonto.

  • Qonto methods bring business records, payments, cards, and invoices into Widefleet.
  • Each Widefleet user connects their own Qonto organization.
  • Qonto changes keep Widefleet and Qonto approvals separate.
  • The generator builds Qonto’s API from split OpenAPI 3.1 pages.

Diagram

sequenceDiagram
  participant W as Widefleet
  participant T as Qonto template
  participant Q as Qonto API
  W->>T: Call a payment method
  opt Widefleet approval is required
    T-->>W: Ask for approval and save the request key
    W->>T: Return the approval and saved state
  end
  T->>Q: Send payment with the request key
  alt Qonto requires phone approval
    Q-->>T: Return an approval session
    T-->>W: Ask the user to approve in Qonto
    W->>T: Return the confirmation and saved state
    T->>Q: Check the session
    alt Allowed
      T->>Q: Resend with the session and same key
    else Waiting or denied
      T-->>W: Ask again or report refusal
    end
  else Qonto accepts the request
    Q-->>T: Return the payment result
  end
Loading

Reviews (5) · Last reviewed commit: "Stop the generator when the rules requir..." · Reviewed by Greptile

Qonto's Business API as 185 typed methods: business accounts,
transactions and attachments, SEPA, internal and international
transfers, beneficiaries, requests, SEPA Direct Debit, cards, clients,
products, client and supplier invoices, quotes, credit notes, payment
links, terminals, memberships, teams, insurance contracts and webhook
subscriptions.

Each organization connects through its own Qonto app for the "Automate
your business operations" use case. Trusting beneficiaries and reviewing
requests are not offered, so Qonto's own approvals stay with the people
Qonto names.

When Qonto answers 428 for its own approval, the method asks the user to
approve in the Qonto app, checks the SCA session when they confirm and
repeats the first request with the session token and the same
idempotency key. Every change carries an idempotency key.

The generator joins descriptions a provider publishes in parts, one
OpenAPI document per reference page, reads OpenAPI 3.1 type lists and
`const`, leaves out `allOf` parts that only annotate and no longer
repeats `null` for enums that list it.
Comment thread templates/qonto/src/run.ts Resolved
Comment thread templates/qonto/src/run.ts Resolved
Comment thread templates/qonto/scripts/operations.ts Resolved
Comment thread templates/qonto/src/schema.ts Resolved
Comment thread templates/qonto/src/rest.ts Resolved
Comment thread templates/qonto/src/run.ts Resolved
Comment thread templates/qonto/src/run.ts Resolved
…onto reads them

- Widefleet's question before a change keeps the request's idempotency
  key, so an answer repeated after a lost response pays once.
- An explicit decline stands even after the user's level stops asking.
- A rate-limited SCA check returns `rate_limited` with `retryAfter`.
- `revokeAccess` removes the saved connection once Qonto confirms.
- `createClientInvoice` and `createRecurringInvoice` send and
  `createCreditNote` updates, since each can reach clients or cancel an
  invoice.
- `createSupplierInvoice` sends one invoice's file, attachment and key
  as the separate parts Qonto reads.

The generator sends a form that carries files as multipart when an
operation also takes a plain form, falls back to the schema's own type
when every `allOf` part only annotates, keeps each type's keywords in
3.1 type unions and compares joined parts regardless of key order.
Comment thread templates/qonto/src/app.ts Outdated
Comment on lines +42 to +43
if (result.status === "connected")
await accountConnection(this.env, this.ctx.props).disconnect();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Revocation can disconnect another account

If a user switches Qonto accounts while revokeAccess waits for Qonto, disconnect() deletes the new link when Qonto confirms revocation of the old one. It matches only the user and provider. Keep track of the grant used for the request and delete the saved link only if it still matches.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 4baf45e. revokeAccess now records which account is connected when it sends the request. Once Qonto confirms, it removes only that account (userId, provider and accountId). The test switches the saved account while Qonto handles the revocation and checks that the new link stays.

Comment thread templates/qonto/scripts/operations.ts Resolved
…oke only the revoked account

- `createSupplierInvoice` takes either a file or an attachment ID, each
  with a required idempotency key, and requires its body.
- `revokeAccess` removes only the account it revoked, so an account the
  user connects meanwhile stays.

The generator takes a `form` rule that replaces a form body's schema,
such as with variants, and requires a form body whose every variant
requires fields.
Comment on lines +914 to +918
const sentForm =
forms.find(
({ kind, entry }) =>
kind === "multipart" && entry.schema && carriesFiles(entry.schema, new Set()),
) ?? forms[0];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 File rules still send text

If an API offers both form formats but its multipart schema doesn't mark a field as a file, adding format: "binary" in rule.form still produces a URL-encoded text field. The generator picks the format before applying the rule. Use the corrected schema to choose the format, and reject file rules if multipart isn't available.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 8de26b4. Choosing the form now also considers files that the rules' form or fields add, so such an operation goes out as multipart even when the description's multipart schema marks no file. Covered by a test.

…and check every form variant

- A body is required when the description or the rules' `requiredBody`
  says so; required fields of an optional form no longer require it.
- Files the rules' form or fields add choose the multipart form, though
  the description's forms carry none.
- A plain form refuses an object field in any variant, also when another
  variant uses the same name for text.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
widefleet-docs f80b659 Nov 24 2026, 06:15 PM

@tnkuehne
tnkuehne merged commit a9ac4bf into main Nov 24, 2026
27 of 29 checks passed
@tnkuehne
tnkuehne deleted the feat/qonto-template branch November 24, 2026 22:06
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