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

支持将swagger扩展属性映射为yapi字段 #2645

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
12 changes: 12 additions & 0 deletions exts/yapi-plugin-import-swagger/run.js
Expand Up @@ -154,6 +154,18 @@ const compareVersions = require('compare-versions');
api.title = data.summary || data.path;
api.desc = data.description;
api.catname = null;

// 处理 swagger 扩展属性
// 如: x-yapi-status 映射为 yapi status字段
const extPrefix = 'x-yapi-';
_.each(api, (value, extfield) => {
if (extfield.startsWith(extPrefix)) {
const yapiField = extfield.replace(extPrefix, '');
api[yapiField] = value;
delete api[extfield];
}
})

if(data.tags && Array.isArray(data.tags)){
api.tag = data.tags;
for(let i=0; i< data.tags.length; i++){
Expand Down