anymaniax / orval

orval is able to generate client with appropriate type-signatures (TypeScript) from any valid OpenAPI v3 or Swagger v2 specification, either in yaml or json formats. 🍺
https://orval.dev
MIT License
2.57k stars 286 forks source link

TS Error: argument of type 'number' is not assignable to parameter of type 'string | Blob' #845

Open chiptus opened 1 year ago

chiptus commented 1 year ago

Wow, this tool is amazing, it has everything we need to make types generation automatic (until now we did by hand when needed)

What are the steps to reproduce this issue?

I have this schema:

/endpoints:
    post:
      consumes:
      - multipart/form-data
      parameters:
      - collectionFormat: csv
        description: List of tag identifiers to which this environment(endpoint) is
          associated
        in: formData
        items:
          type: integer
        name: TagIds
        type: array

What happens?

Screenshot_20230430_184400

What were you expecting to happen?

no error. so code should probably be:

if (endpointCreateBody.TagIds !== undefined) {
    endpointCreateBody.TagIds.forEach((value) =>
      formData.append('TagIds', String(value))
    );
  }

Any logs, error output, etc?

Argument of type 'number' is not assignable to parameter of type 'string | Blob'

What versions are you using?

Operating System: ubuntu Package Version: v6.15.0 Browser Version: not in browser

jamalsoueidan commented 1 year ago

I changed all boolean to string and integer or number to string, I convert them back to number when it hits the endpoint. I don't know if their is any solution to the problem.

export const NumberOrStringType = z
  .union([z.number(), z.string()])
  .transform((value) =>
    typeof value === "string" ? parseInt(value, 10) : value
  );