Skip to content

Stripe form body support - #34

Merged
noha merged 2 commits into
masterfrom
stripe-form-body-support
Jul 30, 2026
Merged

Stripe form body support#34
noha merged 2 commits into
masterfrom
stripe-form-body-support

Conversation

@noha

@noha noha commented Jul 30, 2026

Copy link
Copy Markdown
Member

No description provided.

noha added 2 commits July 30, 2026 11:47
…ity; add Client-Tests package

Stripe's v1 API (the part ApptiveAccount currently uses) is entirely
application/x-www-form-urlencoded, but OAOperation>>applyBody:builder:
always looked up 'application/json' regardless of what the operation
actually declares. Added OARequestBody>>preferredContentType (prefers
form-urlencoded, falls back to json, else whatever is there) and
OAMediaTypeObject>>writeFormBody:builder: as the form-writing counterpart
to the existing JSON writer; applyBody:builder: now picks the writer to
match.

Also, while driving real requests through OpenApiClient against the
Stripe spec + stripe-mock:
- OAMediaTypeObject was missing #encoding: - its own NeoJSON mapping
  declares an accessor pair for #encoding but only the getter existed,
  so parsing any spec using the OpenAPI "encoding" keyword crashed.
- JSONSchemaAnyObject had no #acceptOpenApi: at all (unlike Object/Array,
  which at least have the recurse-later stub) - hit by Stripe's metadata
  schemas, which collapse to an any-type schema.
- OpenApiClient>>operation:arguments:body:beforeSendDo: calls
  #handleError:request:response: but only a 2-arg #handleError:response:
  was defined, so any non-2xx response crashed with doesNotUnderstand
  instead of raising the intended OAUnspecifiedError.

Also fixes OARequestBuilder>>flattenFormParameters:prefix:into: (from the
prior commit) to recognize OrderedDictionary, not just Dictionary -
schema-validated request bodies are read back as NeoJSONObject, which
subclasses OrderedDictionary and does NOT inherit from Dictionary in
Pharo, so it was silently falling through to the scalar branch and
serializing the whole object as one bogus nil-keyed field.

Added the OpenAPI-Client-Tests package (did not exist before - Client had
zero test coverage) with OARequestBuilderTest covering the flatten
function (scalars, nested Dictionary, nested OrderedDictionary/
NeoJSONObject, arrays of objects, deep nesting) and addFormBody:.

All of this was found and verified by actually loading the real Stripe
OpenAPI spec (spec3.json) and driving requests through a live stripe-mock
instance - not just reasoning about the code. POST /v1/customers, DELETE
/v1/customers/{customer} (full round trip), and POST /v1/subscriptions
with nested items[0][price] bracket-notation all build and send
correctly now. Response-body reading for the full Customer/Subscription
response schemas still hits separate, deeper issues (nullable is not
threaded through nested property schemas at all - see the JSONSchema
fixes commit - and likely more undiscovered gaps); that is left for a
follow-up rather than solved here.
@noha
noha merged commit e2eef51 into master Jul 30, 2026
3 of 4 checks passed
@noha
noha deleted the stripe-form-body-support branch July 30, 2026 10:17
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