Skip to content

Commit

Permalink
fix(code-gen/experimental): satisfy typescript when working with uplo…
Browse files Browse the repository at this point in the history
…ad files in the api clients
  • Loading branch information
dirkdev98 committed Apr 14, 2023
1 parent 0a46461 commit d6544a8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/code-gen/src/experimental/api-client/ts-axios.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export function tsAxiosGenerateFunction(
const data = new FormData();
for (const key of Object.keys(files)) {
const keyFiles = Array.isArray(files[key]) ? files[key] : [files[key]];
const keyFiles = Array.isArray((files as any)[key]) ? (files as any)[key] : [(files as any)[key]];
for (const file of keyFiles) {`,
);
Expand Down
2 changes: 1 addition & 1 deletion packages/code-gen/src/experimental/api-client/ts-fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export function tsFetchGenerateFunction(
const data = new FormData();
for (const key of Object.keys(files)) {
const keyFiles = Array.isArray(files[key]) ? files[key] : [files[key]];
const keyFiles = Array.isArray((files as any)[key]) ? (files as any)[key] : [(files as any)[key]];
for (const file of keyFiles) {`,
);
Expand Down
23 changes: 23 additions & 0 deletions packages/code-gen/test/spec/structure.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,5 +141,28 @@ function specificationExtendWithRouteMatchers(generator) {

R.get("/wildcard/*", "wildcardBase"),
R.get("/wildcard/nested/*", "wildcardNested"),

R.post("/types/response/file", "typesResponseFile")
.query({
foo: T.number(),
bar: T.string(),
baz: T.bool(),
})
.body({
nested: {
object: [
{
withArray: true,
},
],
},
})
.response(T.file()),

R.post("/types/input/file", "typesInputFile")
.files({
image: T.file(),
})
.response({}),
);
}

0 comments on commit d6544a8

Please sign in to comment.