Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG][TypeScript-Axios] Boolean field not correctly serialized in FormData #18083

Closed
5 of 6 tasks
dvacca-onfido opened this issue Mar 12, 2024 · 0 comments · Fixed by #18084
Closed
5 of 6 tasks

[BUG][TypeScript-Axios] Boolean field not correctly serialized in FormData #18083

dvacca-onfido opened this issue Mar 12, 2024 · 0 comments · Fixed by #18084

Comments

@dvacca-onfido
Copy link
Contributor

dvacca-onfido commented Mar 12, 2024

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

Generated TypeScript-Axios client is not properly serializing boolean fields part of a multipart/form-data payload, throwing the error TypeError: data should be a string, Buffer or Uint8Array

openapi-generator version

Issue found in version 7.3.0+

OpenAPI declaration file content or url

https://github.com/onfido/onfido-openapi-spec/blob/f600387ed926407964d3aed6beed0f00480d11d4/generated/artifacts/openapi-yaml/openapi/openapi.yaml#L2282-L2285

Generation Details
inputSpec: openapi.yaml
generatorName: typescript-axios
useOneOfDiscriminatorLookup: true
disallowAdditionalPropertiesIfNotPresent: false
npmName: "@onfido/api"
enumUnknownDefaultCase: true
supportsES6: true
apiPackage: api
modelPackage: model
withNodeImports: true
withSeparateModelsAndApi: true
Steps to reproduce
import { createReadStream } from "fs";
import { DefaultApi, Configuration } from "../onfido-node";

const onfido = new DefaultApi(
  new Configuration({
    apiToken: process.env.API_KEY
  })
);
(async () => {

  let live_photo_file:any = createReadStream("live_photo.jpg")
  let live_photo = await onfido.uploadLivePhoto('random-uuid', live_photo_file, false)
})();

Logs:

onfido-node/node_modules/follow-redirects/index.js:125
    throw new TypeError("data should be a string, Buffer or Uint8Array");
    ^
Related issues/PRs

N/A

Suggest a fix

Boolean should be casted to a valid type, String perhaps (PR coming soon):

# Actual output
localVarFormParams.append('advanced_validation', advancedValidation as any);

# Expected output
localVarFormParams.append('advanced_validation', String(advancedValidation as any));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant