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组件中,ApiResponse 的 schema 参数的处理 #4078

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
30 changes: 29 additions & 1 deletion packages/swagger/src/swaggerExplorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,35 @@
for (const k of keys) {
// 这里是引用,赋值可以直接更改
const tt = resp[k];
if (tt.type) {

/**
* 针对直接配置了scheme的写法 适用于统一的响应格式的情况
*

Check failure on line 649 in packages/swagger/src/swaggerExplorer.ts

View workflow job for this annotation

GitHub Actions / lintAndTestLegacy (lts/*, ubuntu-latest)

Delete `·`

Check failure on line 649 in packages/swagger/src/swaggerExplorer.ts

View workflow job for this annotation

GitHub Actions / lintAndTestLegacy (lts/*, ubuntu-latest)

Trailing spaces not allowed
* 例如以下例子,只需要配置data的类型即可
* ApiOkResponse({
* description: '请求成功描述',
* schema: {
* title: `响应数据`,
* allOf: [
* {
* $ref: getSchemaPath(ResponsOkDto),
* },
* {
* properties: {
* data: Data,
* },
* },
* ],
* },
* })
*/
if (tt.schema) {
tt.content = {
'application/json': {
schema: tt.schema

Check failure on line 671 in packages/swagger/src/swaggerExplorer.ts

View workflow job for this annotation

GitHub Actions / lintAndTestLegacy (lts/*, ubuntu-latest)

Insert `,`
}

Check failure on line 672 in packages/swagger/src/swaggerExplorer.ts

View workflow job for this annotation

GitHub Actions / lintAndTestLegacy (lts/*, ubuntu-latest)

Insert `,`
}

Check failure on line 673 in packages/swagger/src/swaggerExplorer.ts

View workflow job for this annotation

GitHub Actions / lintAndTestLegacy (lts/*, ubuntu-latest)

Insert `;`
} else if (tt.type) {
if (Types.isClass(tt.type)) {
this.parseClzz(tt.type);

Expand Down
Loading