Skip to content

Commit 7982ab9

Browse files
committed
fix: 生成的类型缺少namespace问题
1 parent dad2ac3 commit 7982ab9

17 files changed

+310
-274
lines changed

src/generator/serviceGenarator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ export default class ServiceGenerator {
947947

948948
// 具名 body 场景
949949
if (isReferenceObject(schema)) {
950-
bodySchema.type = `${this.config.namespace}.${bodySchema.type}`;
950+
bodySchema.type = `${bodySchema.type}`;
951951
} else {
952952
bodySchema.isAnonymous = true;
953953
}
@@ -1049,7 +1049,7 @@ export default class ServiceGenerator {
10491049
DEFAULT_SCHEMA) as SchemaObject;
10501050
}
10511051

1052-
responseSchema.type = `${this.config.namespace}.${this.getType(schema, this.config.namespace)}`;
1052+
responseSchema.type = `${this.getType(schema, this.config.namespace)}`;
10531053

10541054
return responseSchema;
10551055
}

src/generator/util.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ export function getDefaultType(
135135
}
136136

137137
if (isReferenceObject(schemaObject)) {
138-
return getRefName(schemaObject);
139-
// return [namespace, getRefName(schemaObject)].filter((s) => s).join('.');
138+
// return getRefName(schemaObject);
139+
return [namespace, getRefName(schemaObject)].filter((s) => s).join('.');
140140
}
141141

142142
let type = schemaObject?.type;

test/__snapshots__/common/小驼峰命名文件和请求函数.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export async function petFindByStatusUsingGet({
152152
params: API.petFindByStatusUsingGetParams;
153153
options?: { [key: string]: unknown };
154154
}) {
155-
return request<Pet[]>('/pet/findByStatus', {
155+
return request<API.Pet[]>('/pet/findByStatus', {
156156
method: 'GET',
157157
params: {
158158
// status has a default value: available
@@ -172,7 +172,7 @@ export async function petFindByTagsUsingGet({
172172
params: API.petFindByTagsUsingGetParams;
173173
options?: { [key: string]: unknown };
174174
}) {
175-
return request<Pet[]>('/pet/findByTags', {
175+
return request<API.Pet[]>('/pet/findByTags', {
176176
method: 'GET',
177177
params: {
178178
...params,
@@ -366,7 +366,7 @@ export type User = {
366366
userStatus?: number;
367367
};
368368

369-
export type UserCreateWithListUsingPostBody = User[];
369+
export type UserCreateWithListUsingPostBody = API.User[];
370370

371371
export type userLoginUsingGetParams = {
372372
/** The user name for login */

test/__snapshots__/common/支持 null 类型作为默认值.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export async function petFindByStatusUsingGet({
152152
params: API.petFindByStatusUsingGetParams;
153153
options?: { [key: string]: unknown };
154154
}) {
155-
return request<Pet[]>('/pet/findByStatus', {
155+
return request<API.Pet[]>('/pet/findByStatus', {
156156
method: 'GET',
157157
params: {
158158
// status has a default value: available
@@ -172,7 +172,7 @@ export async function petFindByTagsUsingGet({
172172
params: API.petFindByTagsUsingGetParams;
173173
options?: { [key: string]: unknown };
174174
}) {
175-
return request<Pet[]>('/pet/findByTags', {
175+
return request<API.Pet[]>('/pet/findByTags', {
176176
method: 'GET',
177177
params: {
178178
...params,
@@ -366,7 +366,7 @@ export type User = {
366366
userStatus: number | null;
367367
};
368368

369-
export type UserCreateWithListUsingPostBody = User[];
369+
export type UserCreateWithListUsingPostBody = API.User[];
370370

371371
export type userLoginUsingGetParams = {
372372
/** The user name for login */

test/__snapshots__/common/正常命名文件和请求函数.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export async function petFindByStatusUsingGet({
131131
params: API.petFindByStatusUsingGetParams;
132132
options?: { [key: string]: unknown };
133133
}) {
134-
return request<Pet[]>('/pet/findByStatus', {
134+
return request<API.Pet[]>('/pet/findByStatus', {
135135
method: 'GET',
136136
params: {
137137
// status has a default value: available
@@ -151,7 +151,7 @@ export async function petFindByTagsUsingGet({
151151
params: API.petFindByTagsUsingGetParams;
152152
options?: { [key: string]: unknown };
153153
}) {
154-
return request<Pet[]>('/pet/findByTags', {
154+
return request<API.Pet[]>('/pet/findByTags', {
155155
method: 'GET',
156156
params: {
157157
...params,
@@ -497,7 +497,7 @@ export type User = {
497497
userStatus?: number;
498498
};
499499

500-
export type UserCreateWithListUsingPostBody = User[];
500+
export type UserCreateWithListUsingPostBody = API.User[];
501501

502502
export type userLoginUsingGetParams = {
503503
/** The user name for login */

0 commit comments

Comments
 (0)