Skip to content

Apple apps (Swift)

App API Credential
A shopping app for one business Storefront API The business’s publishable key, plus the shopper’s customer token
The Sedra merchant and admin app Sedra App API App session from Sign in with Apple or Google
An internal tool for one merchant Do not call the Merchant Agent API from the app. Put a small server in between that holds the sdr_int_ credential. –

A complete, tested example is in Code examples. It reads the business and lists products with async/await and Decodable, with no dependencies.

The Sedra app signs in with Sign in with Apple or Google Sign-In. It sends the provider’s ID token to POST /foulad/app/auth/apple (with the raw nonce whose SHA-256 was given to Apple) or POST /foulad/app/auth/google. Sedra verifies the token (signature, issuer, audience, expiry, nonce) and returns:

  • access_token: 30-minute session token for Authorization: Bearer,
  • refresh_token: single-use. Every refresh returns a new one; reusing an old one revokes the whole session.

Store both in the Keychain. GET /foulad/app/me tells the app which experience to show: super_admin, merchant or applicant.

We evaluated Apple’s Swift OpenAPI Generator against Sedra’s contracts. See the results below.

Tested on 2026-11-28 with swift-openapi-generator 1.14.4, swift-openapi-runtime 1.13.4 and swift-openapi-urlsession 1.4.0 (Swift 6.4, macOS):

Contract Generates Compiles Live call Verdict
Sedra App API Yes, no warnings Yes appMe() without a session returned a typed 401 with error.code == "unauthenticated" Suitable. Recommended if you want a generated client.
Storefront API Yes Yes (about 100 s, large Medusa schema set) getProducts returned HTTP 200 but decoding failed: the official Medusa schema marks fields such as collection_id as required strings, while the API returns null Not suitable yet. Use hand-written Decodable models (see the example) until the upstream schema nullability is fixed.
Merchant Agent API Not tested for apps on purpose – – Server-side only. Do not embed in an app.

Details from the evaluation:

  • Medusa models use allOf, so generated types expose parts as value1, value2 (for example response.value2.products).
  • The Storefront operations declare x-publishable-api-key as a required header parameter, so it is passed per call (headers: .init(xPublishableApiKey: …)).
  • Use the generator’s namingStrategy: idiomatic and accessModifier: public.

Minimal openapi-generator-config.yaml:

generate: [types, client]
accessModifier: public
namingStrategy: idiomatic