Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: swagger query object #2547

Merged
merged 2 commits into from Dec 19, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 18 additions & 3 deletions packages/swagger/src/swaggerExplorer.ts
Expand Up @@ -330,9 +330,24 @@ export class SwaggerExplorer {
if (Types.isClass(currentType)) {
this.parseClzz(currentType);

p.schema = {
$ref: '#/components/schemas/' + currentType.name,
};
if (p.in === 'query') {
// 如果@Query()装饰的 是一个对象,则把该对象的子属性作为多个@Query参数
const schema = this.documentBuilder.getSchema(currentType.name);
for (const pName in schema.properties) {
lhcn marked this conversation as resolved.
Show resolved Hide resolved
const ppt: any = schema.properties[pName];
const pp = {
name: pName,
in: p.in,
};
this.parseFromParamsToP({ metadata: ppt }, pp);
parameters.push(pp);
}
continue;
} else {
p.schema = {
$ref: '#/components/schemas/' + currentType.name,
};
}
} else {
p.schema = {
type: convertSchemaType(currentType?.name ?? currentType),
Expand Down