From 906346c04d10185473f59bc2143e45c8dda9ebfe Mon Sep 17 00:00:00 2001 From: luochao <1055120207@qq.com> Date: Tue, 2 Sep 2025 17:19:25 +0800 Subject: [PATCH] fix: fix bug #445 --- .changeset/lemon-webs-write.md | 5 +++++ .prettierignore | 1 + openapi-ts-request.cache.json | 2 +- src/generator/serviceGenarator.ts | 2 +- ...214\350\257\267\346\261\202\345\207\275\346\225\260.snap" | 2 +- ...234\344\270\272\351\273\230\350\256\244\345\200\274.snap" | 2 +- ...214\350\257\267\346\261\202\345\207\275\346\225\260.snap" | 2 +- ...50\213\261\346\226\207 tag \345\220\215\347\247\260.snap" | 2 +- 8 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 .changeset/lemon-webs-write.md create mode 100644 .prettierignore diff --git a/.changeset/lemon-webs-write.md b/.changeset/lemon-webs-write.md new file mode 100644 index 0000000..fbc4b1d --- /dev/null +++ b/.changeset/lemon-webs-write.md @@ -0,0 +1,5 @@ +--- +'openapi-ts-request': patch +--- + +fix: fix bug #445 diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..750c2be --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +openapi-ts-request.cache.json \ No newline at end of file diff --git a/openapi-ts-request.cache.json b/openapi-ts-request.cache.json index 5826eaa..6e4e3a2 100644 --- a/openapi-ts-request.cache.json +++ b/openapi-ts-request.cache.json @@ -4,4 +4,4 @@ "用户": "user", "宠物们": "pets", "你好": "hello" -} +} \ No newline at end of file diff --git a/src/generator/serviceGenarator.ts b/src/generator/serviceGenarator.ts index 220baf6..8ed931e 100644 --- a/src/generator/serviceGenarator.ts +++ b/src/generator/serviceGenarator.ts @@ -1048,7 +1048,7 @@ export default class ServiceGenerator { const response: ResponseObject | undefined = responses && this.resolveRefObject( - responses.default || responses['200'] || responses['201'] + responses['200'] || responses['201'] || responses.default ); const defaultResponse = { mediaType: '*/*', diff --git "a/test/__snapshots__/common/\345\260\217\351\251\274\345\263\260\345\221\275\345\220\215\346\226\207\344\273\266\345\222\214\350\257\267\346\261\202\345\207\275\346\225\260.snap" "b/test/__snapshots__/common/\345\260\217\351\251\274\345\263\260\345\221\275\345\220\215\346\226\207\344\273\266\345\222\214\350\257\267\346\261\202\345\207\275\346\225\260.snap" index 56d59c9..883aa95 100644 --- "a/test/__snapshots__/common/\345\260\217\351\251\274\345\263\260\345\221\275\345\220\215\346\226\207\344\273\266\345\222\214\350\257\267\346\261\202\345\207\275\346\225\260.snap" +++ "b/test/__snapshots__/common/\345\260\217\351\251\274\345\263\260\345\221\275\345\220\215\346\226\207\344\273\266\345\222\214\350\257\267\346\261\202\345\207\275\346\225\260.snap" @@ -682,7 +682,7 @@ export async function userCreateWithListUsingPost({ body: API.UserCreateWithListUsingPostBody; options?: { [key: string]: unknown }; }) { - return request('/user/createWithList', { + return request('/user/createWithList', { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git "a/test/__snapshots__/common/\346\224\257\346\214\201 null \347\261\273\345\236\213\344\275\234\344\270\272\351\273\230\350\256\244\345\200\274.snap" "b/test/__snapshots__/common/\346\224\257\346\214\201 null \347\261\273\345\236\213\344\275\234\344\270\272\351\273\230\350\256\244\345\200\274.snap" index 5cd6ba5..68a674d 100644 --- "a/test/__snapshots__/common/\346\224\257\346\214\201 null \347\261\273\345\236\213\344\275\234\344\270\272\351\273\230\350\256\244\345\200\274.snap" +++ "b/test/__snapshots__/common/\346\224\257\346\214\201 null \347\261\273\345\236\213\344\275\234\344\270\272\351\273\230\350\256\244\345\200\274.snap" @@ -682,7 +682,7 @@ export async function userCreateWithListUsingPost({ body: API.UserCreateWithListUsingPostBody; options?: { [key: string]: unknown }; }) { - return request('/user/createWithList', { + return request('/user/createWithList', { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git "a/test/__snapshots__/common/\346\255\243\345\270\270\345\221\275\345\220\215\346\226\207\344\273\266\345\222\214\350\257\267\346\261\202\345\207\275\346\225\260.snap" "b/test/__snapshots__/common/\346\255\243\345\270\270\345\221\275\345\220\215\346\226\207\344\273\266\345\222\214\350\257\267\346\261\202\345\207\275\346\225\260.snap" index 56d59c9..883aa95 100644 --- "a/test/__snapshots__/common/\346\255\243\345\270\270\345\221\275\345\220\215\346\226\207\344\273\266\345\222\214\350\257\267\346\261\202\345\207\275\346\225\260.snap" +++ "b/test/__snapshots__/common/\346\255\243\345\270\270\345\221\275\345\220\215\346\226\207\344\273\266\345\222\214\350\257\267\346\261\202\345\207\275\346\225\260.snap" @@ -682,7 +682,7 @@ export async function userCreateWithListUsingPost({ body: API.UserCreateWithListUsingPostBody; options?: { [key: string]: unknown }; }) { - return request('/user/createWithList', { + return request('/user/createWithList', { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git "a/test/__snapshots__/common/\346\265\213\350\257\225\345\260\206\344\270\255\346\226\207 tag \345\220\215\347\247\260\347\277\273\350\257\221\346\210\220\350\213\261\346\226\207 tag \345\220\215\347\247\260.snap" "b/test/__snapshots__/common/\346\265\213\350\257\225\345\260\206\344\270\255\346\226\207 tag \345\220\215\347\247\260\347\277\273\350\257\221\346\210\220\350\213\261\346\226\207 tag \345\220\215\347\247\260.snap" index 11cf844..9d4003b 100644 --- "a/test/__snapshots__/common/\346\265\213\350\257\225\345\260\206\344\270\255\346\226\207 tag \345\220\215\347\247\260\347\277\273\350\257\221\346\210\220\350\213\261\346\226\207 tag \345\220\215\347\247\260.snap" +++ "b/test/__snapshots__/common/\346\265\213\350\257\225\345\260\206\344\270\255\346\226\207 tag \345\220\215\347\247\260\347\277\273\350\257\221\346\210\220\350\213\261\346\226\207 tag \345\220\215\347\247\260.snap" @@ -660,7 +660,7 @@ export async function userCreateWithListUsingPost({ body: API.UserCreateWithListUsingPostBody; options?: { [key: string]: unknown }; }) { - return request('/user/createWithList', { + return request('/user/createWithList', { method: 'POST', headers: { 'Content-Type': 'application/json',