Skip to content

Commit 7582122

Browse files
authored
Merge pull request #42 from povio/feat/file-upload-method
fix file upload method based on defined method by params
2 parents a8f58ad + dbfd7f3 commit 7582122

3 files changed

Lines changed: 4 additions & 3 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@povio/openapi-codegen-cli",
3-
"version": "1.2.7",
3+
"version": "1.2.8",
44
"main": "./dist/index.js",
55
"bin": {
66
"openapi-codegen": "./dist/sh.js"

src/generators/templates/partials/query-use-mutation.hbs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ export const {{queryName endpoint mutation=true}} = (options?: AppMutationOption
1313
{{#if endpoint.mediaUpload}}const uploadInstructions = await {{importedEndpointName endpoint}}({{{endpointArgs endpoint}}}{{#if hasAxiosRequestConfig}}{{#if (endpointArgs endpoint)}}, {{/if}}{{axiosRequestConfigName}}{{/if}});
1414

1515
if (file && uploadInstructions.url) {
16-
await axios.put(uploadInstructions.url, file, {
16+
const method = (data?.method?.toLowerCase() ?? "put") as 'put' | 'post';
17+
await axios[method](uploadInstructions.url, file, {
1718
headers: {
1819
"Content-Type": file.type,
1920
},

src/generators/utils/generate/generate.endpoints.utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export function mapEndpointParamsToFunctionParams(
7474
name: "file",
7575
type: "File",
7676
paramType: "Body",
77-
required: true,
77+
required: false,
7878
parameterObject: undefined,
7979
bodyObject: undefined,
8080
});

0 commit comments

Comments
 (0)