Skip to content

Commit

Permalink
Support non-merged SwaggerBake config #241
Browse files Browse the repository at this point in the history
Resolves issue where configs are merged instead of overwritten in multiple SwaggerBake instance scenarios.

Updates documentation to specify using merge false when loading additional swagger bake configs.
  • Loading branch information
cnizzardini committed Jan 17, 2021
1 parent 2aaefb9 commit dcebe05
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ configurations should point to your plugins paths and namespaces. Next, create a
```php
public function initialize(): void
{
parent::initialize(); // TODO: Change the autogenerated stub
Configure::load('OtherApi.swagger_bake', 'default');
parent::initialize();
Configure::load('OtherApi.swagger_bake', 'default', false); // note: `false` for the third argument is important
$this->loadComponent('SwaggerBake.SwaggerUi');
}
```
Expand Down
5 changes: 3 additions & 2 deletions src/Controller/Component/SwaggerUiComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ class SwaggerUiComponent extends Component
public function __construct(ComponentRegistry $registry, array $config = [])
{
parent::__construct($registry, $config);
$this->config = new Configuration();
$this->swagger = (new SwaggerFactory())->create();
}

/**
Expand All @@ -48,6 +46,9 @@ public function __construct(ComponentRegistry $registry, array $config = [])
*/
public function beforeFilter(Event $event): void
{
$this->config = new Configuration();
$this->swagger = (new SwaggerFactory())->create();

if ($this->config->isHotReload()) {
$output = $this->config->getJson();
$this->swagger->writeFile($output);
Expand Down

0 comments on commit dcebe05

Please sign in to comment.