Open cowlicks opened 1 week ago
I think this proximate failure may be addressed by the fix for https://github.com/oxidecomputer/typify/issues/616. Once I try that I get:
gen fail: UnexpectedFormat("unsupported style of query parameter DeepObject")
Error: generation experienced errors
This seems to be caused by this:
"/v1/account": {
"get": {
"description": "<p>Retrieves the details of an account.</p>",
"operationId": "GetAccount",
"parameters": [
{
"description": "Specifies which fields in the response should be expanded.",
"explode": true,
"in": "query",
"name": "expand",
"required": false,
"schema": {
"items": {
"maxLength": 5000,
"type": "string"
},
"type": "array"
},
"style": "deepObject"
}
],
It's a bit confusing: style: deepObject
is only defined for non-nested objects; it's behavior for arrays is undefined.
I see other uses of style: deepObject
that would take some work to support...
FWIW I moved on to using async-stripe
, however they are using the OpenAPI spec to generate their client. That code is here: https://github.com/arlyon/async-stripe/tree/master/openapi
That seems like a good option!
Some notes for myself if we get back here: async-stripe
appears to be partially hand-written and tailored particularly to the Stripe API. For example, it contains special handling for this "expand" query parameter:
It uses serde_qs
, but that seems to produce output different than what the Stripe docs describe. For example:
Stripe docs:
curl https://api.stripe.com/v1/charges/ch_3LmzzQ2eZvKYlo2C0XjzUzJV \
-u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
-d "expand[]"=customer \
-d "expand[]"="invoice.subscription" \
-G
serde_qs:
#[derive(Deserialize, Serialize, Debug, Clone)]
struct Foo {
expand: Vec<String>,
}
fn main() {
let foo = Foo {
expand: vec!["customer".to_string(), "invoice.subscription".to_string()],
};
let out = serde_qs::to_string(&foo).unwrap();
assert_eq!(out, "expand[0]=customer&expand[1]=invoice.subscription");
}
I'd bet that the Stripe API is using Javascript's qs
or something similar so it probably accepts that as well (even though serde_qs doesn't accept the form with indices present).
The OpenAPI spec is here.
The failure is at "
typify-288d5a84bbbe6a46/25e11d8/typify-impl/src/util.rs:246:25:
"When building with the macro, the error comes from a proc macro panic which offers very little context:
I got more info running it from a
build.rs
: