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

FormData date type casted with qutoes #622

Open
WildEgo opened this issue May 24, 2024 · 6 comments
Open

FormData date type casted with qutoes #622

WildEgo opened this issue May 24, 2024 · 6 comments
Labels
bug 🔥 Something isn't working question Further information is requested

Comments

@WildEgo
Copy link

WildEgo commented May 24, 2024

Description

After running the code below with a new Date() the code gets parsed as the snippet below the code, I'd expect it to return 2024-05-22T23:00:00.000Z as opposed to "2024-05-22T23:00:00.000Z"

RequestsService.storeRequest({
  formData: payload,
});
-----------------------------52018713130791794643838276982
Content-Disposition: form-data; name="01HYDKBR6VACJAJ8HVEYEZKF4X"

"2024-05-22T23:00:00.000Z"

OpenAPI specification (optional)

No response

Configuration

No response

System information (optional)

OS: EndeavourOS rolling x86_64
Browser: Firefox, Opera, Chromium
Bun version: 1.1.8

@WildEgo WildEgo added the bug 🔥 Something isn't working label May 24, 2024
@mrlubos
Copy link
Contributor

mrlubos commented May 24, 2024

Hey, can you share your config, which version you're on, and OpenAPI spec?

@mrlubos mrlubos added the question Further information is requested label May 24, 2024
@WildEgo
Copy link
Author

WildEgo commented May 24, 2024

Hey, can you share your config, which version you're on, and OpenAPI spec?

Version should be 0.45.1, the config is below

import { defineConfig } from '@hey-api/openapi-ts';

export default defineConfig({
  client: 'fetch',
  input: '../dashboard/api.json',
  output: {
    format: false,
    lint: false,
    path: 'src/client',
  },
  types: {
    enums: 'typescript',
  },
});

@mrlubos
Copy link
Contributor

mrlubos commented May 24, 2024

I assume the same happens with the latest version? Can you share your OpenAPI spec?

@WildEgo
Copy link
Author

WildEgo commented May 24, 2024

I assume the same happens with the latest version? Can you share your OpenAPI spec?

Yes it does happen on 0.46.2, I can provide the spec but it's not gonna do much for this specifically this is the part that is probably causing the issue, I should add that it generates the code below, I'll also add an expected behaviour

        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "additionalProperties": {
                  "type": "{}"
                }
              }
            }
          }
        },

Generates:

export type StoreRequestData = {
    acceptLanguage?: string;
    formData?: {
        [key: string]: ();
    };
    service: string;
};

I'd expect it to be

export type StoreRequestData = {
    acceptLanguage?: string;
    formData?: {
        [key: string]: unknown;
    };
    service: string;
};

@mrlubos
Copy link
Contributor

mrlubos commented May 24, 2024

Great, thanks! And what does your payload passed to form data look like?

@WildEgo
Copy link
Author

WildEgo commented May 24, 2024

Great, thanks! And what does your payload passed to form data look like?

It's a simple structure, there's no depth, some values are string, some are Date some are File, I haven't had a look at the files, I'll have to see if they work or not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🔥 Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants