Comments (8)
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.
@kumboleijo Did you ever figure out what caused this issue?
from openapi-typescript-codegen.
@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.
@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.
@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.
@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 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.
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)
- A flag to determine file extensions in import statements HOT 1
- Property name with dashes cause incorrect typescript conversion HOT 2
- Behavior change for relative input path in 0.26.0 HOT 19
- parameter with same name as schema conflicts HOT 11
- Type error: Type alias ‘XXX’ circularly references itself. HOT 14
- getFormData causes issue in submitting files HOT 1
- Type error: Private identifiers are only available when targeting ECMAScript 2015 and higher. HOT 22
- Relative external references for Angular client doesn't work HOT 1
- OpenAPI.ts `Resolver` typing is annoying, should use a `Maybe` type
- While resolving: [email protected] HOT 1
- Unable to run when redocly is installed HOT 2
- Option to rename `requestBody` HOT 1
- Select/Filter Tags to generate specific Services only HOT 1
- Literal fields are converted to optional any HOT 5
- Adding the option to remove certain or all file headers. HOT 1
- Referenced nullable object types are not generated as possibly null HOT 4
- anyOf combining literals and objects generates incorrect code HOT 6
- Ability to process multiple input files HOT 5
- all Of -> $reference. HOT 3
- If all parameters are optional, make the top level object optional too HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openapi-typescript-codegen.