Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/old-moments-share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'openapi-ts-request': patch
---

fix: fix global File type conflict #507
4 changes: 2 additions & 2 deletions templates/serviceController.njk
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
{%- for file in api.file -%}
{{ file.title | safe }}
{{- "?" if not api.file.required -}}
: File {{ "[]" if file.multiple }}
: globalThis.File {{ "[]" if file.multiple }}
{{ ";" if not loop.last }}
{%- endfor -%}
{%- endif -%}
Expand Down Expand Up @@ -105,7 +105,7 @@
{% endif %}
if (item !== undefined && item !== null) {
{% if genType === "ts" %}
if (typeof item === 'object' && !(item instanceof File)) {
if (typeof item === 'object' && !(item instanceof globalThis.File)) {
if (item instanceof Array) {
item.forEach((f) => formData.append(ele, f || ''));
} else {
Expand Down
4 changes: 2 additions & 2 deletions test/__snapshots__/common/文件上传.snap
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function webapiClearImportNavReCheckFileUsingPost({
options,
}: {
body: API.WebapiClearImportNavReCheckFileUsingPostBody;
file?: File;
file?: globalThis.File;
options?: { [key: string]: unknown };
}) {
const formData = new FormData();
Expand All @@ -52,7 +52,7 @@ export function webapiClearImportNavReCheckFileUsingPost({
const item = (body as { [key: string]: any })[ele];

if (item !== undefined && item !== null) {
if (typeof item === 'object' && !(item instanceof File)) {
if (typeof item === 'object' && !(item instanceof globalThis.File)) {
if (item instanceof Array) {
item.forEach((f) => formData.append(ele, f || ''));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ export function adminUtilsUploadsUsingPost({
options,
}: {
body: API.AdminUtilsUploadsUsingPostBody;
file?: File;
file?: globalThis.File;
options?: { [key: string]: unknown };
}) {
const formData = new FormData();
Expand All @@ -987,7 +987,7 @@ export function adminUtilsUploadsUsingPost({
const item = (body as { [key: string]: any })[ele];

if (item !== undefined && item !== null) {
if (typeof item === 'object' && !(item instanceof File)) {
if (typeof item === 'object' && !(item instanceof globalThis.File)) {
if (item instanceof Array) {
item.forEach((f) => formData.append(ele, f || ''));
} else {
Expand Down
2 changes: 1 addition & 1 deletion test/__snapshots__/common/测试生成 JSON Schemas.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1421,7 +1421,7 @@ export function v2ApiFileUsingPost({
const item = (body as { [key: string]: any })[ele];

if (item !== undefined && item !== null) {
if (typeof item === 'object' && !(item instanceof File)) {
if (typeof item === 'object' && !(item instanceof globalThis.File)) {
if (item instanceof Array) {
item.forEach((f) => formData.append(ele, f || ''));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2653,7 +2653,7 @@ export function v2ApiFileUsingPost({
const item = (body as { [key: string]: any })[ele];

if (item !== undefined && item !== null) {
if (typeof item === 'object' && !(item instanceof File)) {
if (typeof item === 'object' && !(item instanceof globalThis.File)) {
if (item instanceof Array) {
item.forEach((f) => formData.append(ele, f || ''));
} else {
Expand Down
2 changes: 1 addition & 1 deletion test/__snapshots__/common/测试生成 react-query.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2741,7 +2741,7 @@ export function v2ApiFileUsingPost({
const item = (body as { [key: string]: any })[ele];

if (item !== undefined && item !== null) {
if (typeof item === 'object' && !(item instanceof File)) {
if (typeof item === 'object' && !(item instanceof globalThis.File)) {
if (item instanceof Array) {
item.forEach((f) => formData.append(ele, f || ''));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export function petPetIdUploadImageUsingPost({
// 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
params: API.PetPetIdUploadImageUsingPostParams;
body: API.PetPetIdUploadImageUsingPostBody;
file?: File;
file?: globalThis.File;
options?: { [key: string]: unknown };
}) {
const { petId: param0, ...queryParams } = params;
Expand All @@ -145,7 +145,7 @@ export function petPetIdUploadImageUsingPost({
const item = (body as { [key: string]: any })[ele];

if (item !== undefined && item !== null) {
if (typeof item === 'object' && !(item instanceof File)) {
if (typeof item === 'object' && !(item instanceof globalThis.File)) {
if (item instanceof Array) {
item.forEach((f) => formData.append(ele, f || ''));
} else {
Expand Down
4 changes: 2 additions & 2 deletions test/__snapshots__/common/测试设置 path 前缀.snap
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export function petPetIdUploadImageUsingPost({
// 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
params: API.PetPetIdUploadImageUsingPostParams;
body: API.PetPetIdUploadImageUsingPostBody;
file?: File;
file?: globalThis.File;
options?: { [key: string]: unknown };
}) {
const { petId: param0, ...queryParams } = params;
Expand All @@ -145,7 +145,7 @@ export function petPetIdUploadImageUsingPost({
const item = (body as { [key: string]: any })[ele];

if (item !== undefined && item !== null) {
if (typeof item === 'object' && !(item instanceof File)) {
if (typeof item === 'object' && !(item instanceof globalThis.File)) {
if (item instanceof Array) {
item.forEach((f) => formData.append(ele, f || ''));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3265,7 +3265,7 @@ export function v2ApiFileUsingPost({
const item = (body as { [key: string]: any })[ele];

if (item !== undefined && item !== null) {
if (typeof item === 'object' && !(item instanceof File)) {
if (typeof item === 'object' && !(item instanceof globalThis.File)) {
if (item instanceof Array) {
item.forEach((f) => formData.append(ele, f || ''));
} else {
Expand Down