Skip to content

Commit a9da8c3

Browse files
fix: fix global File type conflict #507
1 parent a86c613 commit a9da8c3

10 files changed

+19
-14
lines changed

.changeset/old-moments-share.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'openapi-ts-request': patch
3+
---
4+
5+
fix: fix global File type conflict #507

templates/serviceController.njk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
{%- for file in api.file -%}
6565
{{ file.title | safe }}
6666
{{- "?" if not api.file.required -}}
67-
: File {{ "[]" if file.multiple }}
67+
: globalThis.File {{ "[]" if file.multiple }}
6868
{{ ";" if not loop.last }}
6969
{%- endfor -%}
7070
{%- endif -%}
@@ -105,7 +105,7 @@
105105
{% endif %}
106106
if (item !== undefined && item !== null) {
107107
{% if genType === "ts" %}
108-
if (typeof item === 'object' && !(item instanceof File)) {
108+
if (typeof item === 'object' && !(item instanceof globalThis.File)) {
109109
if (item instanceof Array) {
110110
item.forEach((f) => formData.append(ele, f || ''));
111111
} else {

test/__snapshots__/common/文件上传.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export function webapiClearImportNavReCheckFileUsingPost({
3939
options,
4040
}: {
4141
body: API.WebapiClearImportNavReCheckFileUsingPostBody;
42-
file?: File;
42+
file?: globalThis.File;
4343
options?: { [key: string]: unknown };
4444
}) {
4545
const formData = new FormData();
@@ -52,7 +52,7 @@ export function webapiClearImportNavReCheckFileUsingPost({
5252
const item = (body as { [key: string]: any })[ele];
5353

5454
if (item !== undefined && item !== null) {
55-
if (typeof item === 'object' && !(item instanceof File)) {
55+
if (typeof item === 'object' && !(item instanceof globalThis.File)) {
5656
if (item instanceof Array) {
5757
item.forEach((f) => formData.append(ele, f || ''));
5858
} else {

test/__snapshots__/common/测试 swagger =_ openapi, schema 循环引用.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,7 @@ export function adminUtilsUploadsUsingPost({
974974
options,
975975
}: {
976976
body: API.AdminUtilsUploadsUsingPostBody;
977-
file?: File;
977+
file?: globalThis.File;
978978
options?: { [key: string]: unknown };
979979
}) {
980980
const formData = new FormData();
@@ -987,7 +987,7 @@ export function adminUtilsUploadsUsingPost({
987987
const item = (body as { [key: string]: any })[ele];
988988

989989
if (item !== undefined && item !== null) {
990-
if (typeof item === 'object' && !(item instanceof File)) {
990+
if (typeof item === 'object' && !(item instanceof globalThis.File)) {
991991
if (item instanceof Array) {
992992
item.forEach((f) => formData.append(ele, f || ''));
993993
} else {

test/__snapshots__/common/测试生成 JSON Schemas.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1421,7 +1421,7 @@ export function v2ApiFileUsingPost({
14211421
const item = (body as { [key: string]: any })[ele];
14221422

14231423
if (item !== undefined && item !== null) {
1424-
if (typeof item === 'object' && !(item instanceof File)) {
1424+
if (typeof item === 'object' && !(item instanceof globalThis.File)) {
14251425
if (item instanceof Array) {
14261426
item.forEach((f) => formData.append(ele, f || ''));
14271427
} else {

test/__snapshots__/common/测试生成 react-query 的 vue 模式.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2653,7 +2653,7 @@ export function v2ApiFileUsingPost({
26532653
const item = (body as { [key: string]: any })[ele];
26542654

26552655
if (item !== undefined && item !== null) {
2656-
if (typeof item === 'object' && !(item instanceof File)) {
2656+
if (typeof item === 'object' && !(item instanceof globalThis.File)) {
26572657
if (item instanceof Array) {
26582658
item.forEach((f) => formData.append(ele, f || ''));
26592659
} else {

test/__snapshots__/common/测试生成 react-query.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2741,7 +2741,7 @@ export function v2ApiFileUsingPost({
27412741
const item = (body as { [key: string]: any })[ele];
27422742

27432743
if (item !== undefined && item !== null) {
2744-
if (typeof item === 'object' && !(item instanceof File)) {
2744+
if (typeof item === 'object' && !(item instanceof globalThis.File)) {
27452745
if (item instanceof Array) {
27462746
item.forEach((f) => formData.append(ele, f || ''));
27472747
} else {

test/__snapshots__/common/测试解析 swagger.yaml_openapi.yaml.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export function petPetIdUploadImageUsingPost({
131131
// 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
132132
params: API.PetPetIdUploadImageUsingPostParams;
133133
body: API.PetPetIdUploadImageUsingPostBody;
134-
file?: File;
134+
file?: globalThis.File;
135135
options?: { [key: string]: unknown };
136136
}) {
137137
const { petId: param0, ...queryParams } = params;
@@ -145,7 +145,7 @@ export function petPetIdUploadImageUsingPost({
145145
const item = (body as { [key: string]: any })[ele];
146146

147147
if (item !== undefined && item !== null) {
148-
if (typeof item === 'object' && !(item instanceof File)) {
148+
if (typeof item === 'object' && !(item instanceof globalThis.File)) {
149149
if (item instanceof Array) {
150150
item.forEach((f) => formData.append(ele, f || ''));
151151
} else {

test/__snapshots__/common/测试设置 path 前缀.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export function petPetIdUploadImageUsingPost({
131131
// 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
132132
params: API.PetPetIdUploadImageUsingPostParams;
133133
body: API.PetPetIdUploadImageUsingPostBody;
134-
file?: File;
134+
file?: globalThis.File;
135135
options?: { [key: string]: unknown };
136136
}) {
137137
const { petId: param0, ...queryParams } = params;
@@ -145,7 +145,7 @@ export function petPetIdUploadImageUsingPost({
145145
const item = (body as { [key: string]: any })[ele];
146146

147147
if (item !== undefined && item !== null) {
148-
if (typeof item === 'object' && !(item instanceof File)) {
148+
if (typeof item === 'object' && !(item instanceof globalThis.File)) {
149149
if (item instanceof Array) {
150150
item.forEach((f) => formData.append(ele, f || ''));
151151
} else {

test/__snapshots__/common/生成枚举翻译, 生成 type 翻译.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3265,7 +3265,7 @@ export function v2ApiFileUsingPost({
32653265
const item = (body as { [key: string]: any })[ele];
32663266

32673267
if (item !== undefined && item !== null) {
3268-
if (typeof item === 'object' && !(item instanceof File)) {
3268+
if (typeof item === 'object' && !(item instanceof globalThis.File)) {
32693269
if (item instanceof Array) {
32703270
item.forEach((f) => formData.append(ele, f || ''));
32713271
} else {

0 commit comments

Comments
 (0)