Skip to content

Commit

Permalink
fix(swagger): 修复多标签问题,以及添加默认名称 (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
StringKe authored Oct 13, 2022
1 parent 6bc88c5 commit 2a44abe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 7 additions & 1 deletion packages/api/src/swagger/createTypeFileName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 7,11 @@ export function createTypeFileName(swaggerTagName: string) {

swaggerTagName_ = pinyin(swaggerTagName_, { toneType: 'none' })

return swaggerTagName_.replace(/\s/g, '')
swaggerTagName_ = swaggerTagName_.replace(/\s/g, '')

if (swaggerTagName_.length === 0) {
swaggerTagName_ = 'Default'
}

return swaggerTagName_
}
4 changes: 3 additions & 1 deletion packages/api/src/swagger/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 46,9 @@ export async function transform(
for (const key in paths) {
const method = Object.keys(paths[key])[0] as string
const item = paths[key][method]
const moduleName = item.tags[0]
const moduleName = modules
? item.tags.find((it) => modules.includes(it))
: item.tags[0]

if (!modules || modules.length === 0 || modules.includes(moduleName)) {
if (!result[moduleName]) {
Expand Down

0 comments on commit 2a44abe

Please sign in to comment.