Skip to content

Commit

Permalink
TypeRegistry
Browse files Browse the repository at this point in the history
  • Loading branch information
vanderlee committed Apr 17, 2018
1 parent fb14302 commit 6bd2c87
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions SwaggerGen/SwaggerGen.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ public function __construct($host = '', $basePath = '', $dirs = array(), $typeRe
$this->dirs = $dirs;
$this->typeRegistry = $typeRegistry;
}

/**
* Set a new type registry
*
* @param TypeRegistry $typeRegistry
*/
public function setTypeRegistry($typeRegistry = null)
{
$this->typeRegistry = $typeRegistry;
}

public function define($name, $value = 1)
{
Expand Down
3 changes: 2 additions & 1 deletion example/api/swagger.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
// \SwaggerGen\Swagger\Type\Custom\Ipv4Type::setFormats(array('ipv4'));
$TypeRegistry->add('\SwaggerGen\Swagger\Type\Custom\Ipv4Type');

$SwaggerGen = new \SwaggerGen\SwaggerGen($_SERVER['HTTP_HOST'], dirname($_SERVER['REQUEST_URI']), array(), $TypeRegistry);
$SwaggerGen = new \SwaggerGen\SwaggerGen($_SERVER['HTTP_HOST'], dirname($_SERVER['REQUEST_URI']), array());
$SwaggerGen->setTypeRegistry($TypeRegistry);

// @todo Allow explicitly format name specification for conflict resolution.
// @todo Automatically scan the default types (how to register multiple type names; e.g. StringType's names)
Expand Down

0 comments on commit 6bd2c87

Please sign in to comment.