Skip to content

Unknown fields of API resources get dropped even if using --output json #2

Description

@fjbender

An effect of using mollie/mollie-api-golang is that it only casts known fields into resource representations and swallows undocumented parameters.

When testing new functionality, this can lead to new parameters not being returned even in --output json mode, because the JSON output is based on the Speakeasy representation, not the raw JSON response from the API (meaning the chain goes JSON -> Speakeasy Object -> JSON).

mollie-cli/cmd/mandates.go

Lines 206 to 219 in bb1fa52

resp, err := client.Mandates.List(context.Background(), req)
if err != nil {
return fmt.Errorf("listing mandates: %w", err)
}
if resp.Object == nil {
return nil
}
manEmbedded := resp.Object.GetEmbedded()
mandates := manEmbedded.GetMandates()
switch resolvedOutput() {
case output.FormatJSON:
return output.PrintJSON(resp.Object)

One possible solution might be to bypass casting the API response into the Speakeasy representation if output mode is JSON or YAML, and return the raw response instead. There might be other, better solutions.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions