Code Monkey home page Code Monkey logo

Comments (8)

costa-collibra avatar costa-collibra commented on June 2, 2024 1

I have also had this exact same issue when trying to use the generated code to upload a file. For now I have had to build my own request using axios. I am using the client in my e2e Playwright tests for creating test data.

I can provide more context if and examples if you are looking into this issue.

Thanks

from openapi-typescript-codegen.

melanki avatar melanki commented on June 2, 2024

@kumboleijo Did you ever figure out what caused this issue?

from openapi-typescript-codegen.

kumboleijo avatar kumboleijo commented on June 2, 2024

@melanki sadly no. But what I can say is, that it is working in browser based environments (React App built with vite). Not sure if I'm doing something wrong in my typescript setup and mess up with ESM and CJS?

from openapi-typescript-codegen.

kumboleijo avatar kumboleijo commented on June 2, 2024

@costa-collibra Would you mind sharing some more insights on this and what exactly you had to tweak in your custom request in order to get it work? 🙏

from openapi-typescript-codegen.

costa-collibra avatar costa-collibra commented on June 2, 2024

@kumboleijo My choice of words were probably a bit poor. In order to get it to work we couldnt use the library so we used axios directly.

export const uploadZip = async ({ filePath, fileName }: { filePath: string; fileName: string }): Promise<any> => {
  const data = new FormData();
  const setCustomAuthHeader = btoa(
    `${envConfig().CUSTOM_ADMIN_TEST_USERNAME}:${envConfig().CUSTOM_ADMIN_TEST_PASSWORD}`,
  );

  data.append('file', fs.createReadStream(filePath));
  data.append('fileName', fileName);

  const config = {
    method: 'post',
    maxBodyLength: Infinity,
    url: envConfig().BASE_URL + '/rest/2.0/workflowDefinitions',
    headers: {
      Authorization: `Basic ${setCustomAuthHeader}`,
      ...data.getHeaders(),
    },
    data: data,
  };

  const response = await axios.request(config);
  console.log(`RESPONSE: ${JSON.stringify(response.data)}`);

  return response;
};

This is why I think the issue resides in this library as this code is working.

I really hope this gets fixed though so we can go back to library for this endpoint.

from openapi-typescript-codegen.

kumboleijo avatar kumboleijo commented on June 2, 2024

@costa-collibra oh I see... I thought you provided your own custom request file using:

npx openapi-typescript-codegen --input ./spec.json --output ./generated --request ./request.ts

I guess that could be a good workaround for you since you already have custom code written for that call.

from openapi-typescript-codegen.

costa-collibra avatar costa-collibra commented on June 2, 2024

@costa-collibra oh I see... I thought you provided your own custom request file using:

npx openapi-typescript-codegen --input ./spec.json --output ./generated --request ./request.ts

I guess that could be a good workaround for you since you already have custom code written for that call.

I didnt even know this was possible, hopefully its only a temp workaround

from openapi-typescript-codegen.

mluogh avatar mluogh commented on June 2, 2024

I am also experiencing this issue. In another browser based project, I was able to get this working, but I built an Electron app with electon-react-boilerplate and see the issue here.

I also just directly used Axios and made my own FormData() and see no issues with that.

from openapi-typescript-codegen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.