Skip to content

Commit

Permalink
scenarioDefaultDescription: scenarioName, scenarioConst, modelName
Browse files Browse the repository at this point in the history
  • Loading branch information
siggi-k committed Aug 25, 2024
1 parent 19d5c36 commit 69dfc10
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/generator/ApiGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ class ApiGenerator extends Generator
* @var array Map for custom dbModels
* @example
* 'dbModel' => [
* 'scenarioDefaultDescription' => " Scenario {name}", @see DbModel::$scenarioDefaultDescription
* AcceptedInputs: {scenarioName}, {scenarioConst}, {modelName}.
* 'scenarioDefaultDescription' => " Scenario {scenarioName}", @see DbModel::$scenarioDefaultDescription
* ]
*/
public $dbModel = [];
Expand Down
3 changes: 2 additions & 1 deletion src/lib/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ class Config extends BaseObject
* @var array Map for custom dbModels
* @example
* 'dbModel' => [
* 'scenarioDefaultDescription' => " Scenario {name}", @see DbModel::$scenarioDefaultDescription
* AcceptedInputs: {scenarioName}, {scenarioConst}, {modelName}.
* 'scenarioDefaultDescription' => " Scenario {scenarioName}", @see DbModel::$scenarioDefaultDescription
* ]
*/
public $dbModel = [];
Expand Down
15 changes: 11 additions & 4 deletions src/lib/items/DbModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ class DbModel extends BaseObject
/**
* @var string
* Here, you can set your own default description for the scenario.
* You can use the {name} attribute from the schema for the YAML model.
* AcceptedInputs: {scenarioName}, {scenarioConst}, {modelName}.
*/
public string $scenarioDefaultDescription = " Scenario {name}";
public string $scenarioDefaultDescription = " Scenario {scenarioName}";

public function getTableAlias():string
{
Expand Down Expand Up @@ -237,8 +237,15 @@ private function getScenariosByOpenapiSchema(): array
$scenarios[$key]['description'] = FormatHelper::getFormattedDescription(
!empty($scenario['description']) ?
$scenario['description']
: str_replace('{name}', $scenario['name'], $this->scenarioDefaultDescription
),
: str_replace([
'{scenarioName}',
'{scenarioConst}',
'{modelName}',
], [
$scenario['name'],
$scenarios[$key]['const'],
$this->name,
], $this->scenarioDefaultDescription),
5);
}

Expand Down

0 comments on commit 69dfc10

Please sign in to comment.