Skip to content

Commit

Permalink
Feat: Support Swagger extension properties
Browse files Browse the repository at this point in the history
  • Loading branch information
mobiusy committed Dec 7, 2022
1 parent 59bade3 commit 8e09bdf
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions exts/yapi-plugin-import-swagger/run.js
Original file line number Diff line number Diff line change
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

0 comments on commit 8e09bdf

Please sign in to comment.