Skip to content

Panic during code generation when using builder style interface + object in query parameters #1221

@ollyswanson

Description

@ollyswanson

Sorry for not putting together something to reproduce the issue:

I'm using the builder-style interface; an OpenAPI spec that I don't control has been updated to specify its query parameters as an object.

I'm hitting a panic here:

// For builder-capable bodies we offer a `body()`
// method that sets the full body (by constructing
// a builder **from** the body type). We also offer
// a `body_map()` method that operates on the
// builder itself.
(Some(builder_name), false) => {
assert_eq!(param.name, "body");
let typ = ty.ident();
let err_msg = format!(
"conversion to `{}` for {} failed: {{}}",
ty.name(),
param.name,
);

Message:  assertion `left == right` failed
  left: "my_object"
 right: "body"

I've tried patching the code generation locally to parameterize the codegen in this branch + remove the assertion - but I haven't had the time to understand the surrounding code yet (and if there's a reason for the assertion beyond "we don't expect any builders that aren't for the body").

Is this just a case of not having implemented #1017 at the time the assertion was written?

The fix appears to be relatively straightforward but I'm struggling to get the time to think it through/follow it through - I just wanted to make sure that I wasn't missing something obvious.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions