1
0
Fork 0
mirror of synced 2024-05-20 12:42:39 +12:00

Added option to hide some models from the docs

This commit is contained in:
Eldad Fux 2020-11-12 07:12:14 +02:00
parent 2750267712
commit e1837c01d5
10 changed files with 69 additions and 9 deletions

View file

@ -276,8 +276,6 @@ App::get('/specs/:format')
foreach ($utopia->getRoutes() as $key => $method) {
foreach ($method as $route) { /** @var \Utopia\Route $route */
var_dump($route->getURL());
if (!$route->getLabel('docs', true)) {
continue;
}
@ -305,6 +303,12 @@ App::get('/specs/:format')
$models = $response->getModels();
foreach ($models as $key => $value) {
if($platform !== APP_PLATFORM_CONSOLE && !$value->isPublic()) {
unset($models[$key]);
}
}
switch ($format) {
case 'swagger2':
$format = new Swagger2($utopia, $routes, $models, $keys[$platform], $security[$platform]);

View file

@ -141,12 +141,12 @@ class Response extends SwooleResponse
->setModel(new BaseList('Functions List', self::MODEL_FUNCTION_LIST, 'functions', self::MODEL_FUNCTION))
->setModel(new BaseList('Tags List', self::MODEL_TAG_LIST, 'tags', self::MODEL_TAG))
->setModel(new BaseList('Executions List', self::MODEL_EXECUTION_LIST, 'executions', self::MODEL_EXECUTION))
->setModel(new BaseList('Projects List', self::MODEL_PROJECT_LIST, 'projects', self::MODEL_PROJECT))
->setModel(new BaseList('Webhooks List', self::MODEL_WEBHOOK_LIST, 'webhooks', self::MODEL_WEBHOOK))
->setModel(new BaseList('API Keys List', self::MODEL_KEY_LIST, 'keys', self::MODEL_KEY))
->setModel(new BaseList('Tasks List', self::MODEL_TASK_LIST, 'tasks', self::MODEL_TASK))
->setModel(new BaseList('Platforms List', self::MODEL_PLATFORM_LIST, 'platforms', self::MODEL_PLATFORM))
->setModel(new BaseList('Domains List', self::MODEL_DOMAIN_LIST, 'domains', self::MODEL_DOMAIN))
->setModel(new BaseList('Projects List', self::MODEL_PROJECT_LIST, 'projects', self::MODEL_PROJECT, true, false))
->setModel(new BaseList('Webhooks List', self::MODEL_WEBHOOK_LIST, 'webhooks', self::MODEL_WEBHOOK, true, false))
->setModel(new BaseList('API Keys List', self::MODEL_KEY_LIST, 'keys', self::MODEL_KEY, true, false))
->setModel(new BaseList('Tasks List', self::MODEL_TASK_LIST, 'tasks', self::MODEL_TASK, true, false))
->setModel(new BaseList('Platforms List', self::MODEL_PLATFORM_LIST, 'platforms', self::MODEL_PLATFORM, true, false))
->setModel(new BaseList('Domains List', self::MODEL_DOMAIN_LIST, 'domains', self::MODEL_DOMAIN, true, false))
->setModel(new BaseList('Countries List', self::MODEL_COUNTRY_LIST, 'countries', self::MODEL_COUNTRY))
->setModel(new BaseList('Continents List', self::MODEL_CONTINENT_LIST, 'continents', self::MODEL_CONTINENT))
->setModel(new BaseList('Languages List', self::MODEL_LANGUAGE_LIST, 'languages', self::MODEL_LANGUAGE))

View file

@ -20,6 +20,11 @@ abstract class Model
*/
protected $any = false;
/**
* @var bool
*/
protected $public = true;
/**
* @var array
*/
@ -102,4 +107,16 @@ abstract class Model
{
return $this->any;
}
/**
* Is Public
*
* Should this model be publicly available in docs and spec files?
*
* @return bool
*/
public function isPublic(): bool
{
return $this->public;
}
}

View file

@ -17,10 +17,19 @@ class BaseList extends Model
*/
protected $type = '';
public function __construct(string $name, string $type, string $key, string $model, bool $paging = true)
/**
* @param string $name
* @param string $type
* @param string $key
* @param string $model
* @param bool $paging
* @param bool $public
*/
public function __construct(string $name, string $type, string $key, string $model, bool $paging = true, bool $public = true)
{
$this->name = $name;
$this->type = $type;
$this->public = $public;
if ($paging) {
$this->addRule('sum', [

View file

@ -7,6 +7,11 @@ use Appwrite\Utopia\Response\Model;
class Domain extends Model
{
/**
* @var bool
*/
protected $public = false;
public function __construct()
{
$this

View file

@ -7,6 +7,11 @@ use Appwrite\Utopia\Response\Model;
class Key extends Model
{
/**
* @var bool
*/
protected $public = false;
public function __construct()
{
$this

View file

@ -7,6 +7,11 @@ use Appwrite\Utopia\Response\Model;
class Platform extends Model
{
/**
* @var bool
*/
protected $public = false;
public function __construct()
{
$this

View file

@ -8,6 +8,11 @@ use Utopia\Config\Config;
class Project extends Model
{
/**
* @var bool
*/
protected $public = false;
public function __construct()
{
$this

View file

@ -7,6 +7,11 @@ use Appwrite\Utopia\Response\Model;
class Task extends Model
{
/**
* @var bool
*/
protected $public = false;
public function __construct()
{
$this

View file

@ -7,6 +7,11 @@ use Appwrite\Utopia\Response\Model;
class Webhook extends Model
{
/**
* @var bool
*/
protected $public = false;
public function __construct()
{
$this