Skip to content

Commit

Permalink
postman 支持新的命名规范
Browse files Browse the repository at this point in the history
  • Loading branch information
朱鹏飞 committed Sep 8, 2020
1 parent 85848f7 commit 089b861
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/Parsers/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ private function initPostmanJson()
// sdk
// sdkPath
$appName = $di->getConfig()->path('app.appName');
$appName = preg_replace("/\-/", '.', $appName);
/*$appName = preg_replace("/\-/", '.', $appName);
$appNameArr = explode('.', $appName);
$appNameDesc = [];
for ($i = count($appNameArr) - 1; $i >= 0; $i--) {
Expand All @@ -244,6 +244,16 @@ private function initPostmanJson()
'union'
])) {
$this->console->warning("应用名称在配置文件[config/app.php]中的[appName]字段值不合法, 必须以module、union、backend结尾");
}*/
$appNameArr = explode('-', $appName);
$appNameAsc = $appNameArr;
$sdkPath = array_shift($appNameArr);
if (!in_array($sdkPath, [
'pm',
'ps',
'px'
])) {
$this->console->warning("应用名称在配置文件[config/app.php]中的[appName]字段值不合法, 必须以pm、ps、px 开头");
}
$sdkClass = preg_replace_callback("/[\.|\-](\w)/", function($a){
return strtoupper($a[1]);
Expand All @@ -256,7 +266,8 @@ private function initPostmanJson()
$data->sdk = $sdkClass;
$data->sdkPath = $sdkPath;
$data->sdkService = $appName;
$data->sdkLink = "https://uniondrug.coding.net/p/".implode(".", $appNameDesc)."/git/blob/development";;
//$data->sdkLink = "https://uniondrug.coding.net/p/".implode(".", $appNameDesc)."/git/blob/development";;
$data->sdkLink = "https://uniondrug.coding.net/p/".implode("-", $appNameAsc)."/git/blob/development";
// 2. 配置文件优选级
$path = "{$this->basePath}/postman.json";
if (file_exists($path)) {
Expand Down

0 comments on commit 089b861

Please sign in to comment.