OpenAPI: Nested Object field incorrectly serialized to string

^^ in query

^^ in debug

Which fails when triggered because the API expects an object not stringified object.

Hey @pckilgore!

Would you mind sharing the specific error you're seeing from your API? Retool will often display stringified bodies that are interpreted as the endpoints as objects so I just want to make sure there isn't something else going on here and it would be helpful to get more context.

This also looks like it's an OpenAPI resource is that correct? Could you share the relevant part of your spec?

The error was roughly "failed to marshal string into struct" with the struct being the exact one I saw as a string in the debug console, so I stopped investigating there.

The real issue was actually a field on that struct should have been either undefined or an array, but was being passed as a string by retool. I guess the golang error gets reported based on the struct the field is a part of not the field itself.

When I fixed that and started passing an empty array not an empty string retool worked fine.

Feedback

  • If you show me a field encoded as a string in the debug tools, I'm going to believe it's a string, not a string representation of an object you will parse before sending.
  • If OpenAPI: Enum field cannot be set dynamically, would have worked, I could have avoided all this by not hand-writing JSON in a fragile raw-js environment.

relevant piece of spec (for both here and my other issue):
image

1 Like

Ah! Nice find :slightly_smiling_face:

Thanks for both pieces of feedback, will pass them along and we'll notify you in each thread with updates!