Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No error when no Schema is available #34

Merged
merged 1 commit into from
May 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions src/DocApp.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Aura\Router\Route;
use Aura\Router\RouterContainer;
use BEAR\AppMeta\Meta;
use BEAR\AppMeta\ResMeta;
use Doctrine\Common\Annotations\Reader;
use FilesystemIterator;
use Generator;
Expand Down Expand Up @@ -67,9 +66,19 @@ public function __construct(string $appName)
$reader = $injector->getInstance(Reader::class);
assert($reader instanceof Reader);
/** @var string responseSchemaDir $responseSchemaDir */
$responseSchemaDir = $injector->getInstance('', 'json_schema_dir');
try {
$responseSchemaDir = $injector->getInstance('', 'json_schema_dir');
} catch (Unbound $e) {
$responseSchemaDir = '';
}

$this->responseSchemaDir = $responseSchemaDir;
$requestSchemaDir = $injector->getInstance('', 'json_validate_dir');
try {
$requestSchemaDir = $injector->getInstance('', 'json_validate_dir');
} catch (Unbound $e) {
$requestSchemaDir = '';
}

assert(is_string($requestSchemaDir));
/** @var ArrayObject<string, string> $modelRepository */
$modelRepository = new ArrayObject();
Expand Down Expand Up @@ -123,7 +132,10 @@ private function getGenMarkdown(string $docDir, string $scheme, string $ext, str
yield $file => $markdown;
}

$this->copySchemas($docDir);
if ($this->responseSchemaDir) {
$this->copySchemas($docDir);
}

/** @var list<string> $objects */
$objects = array_unique((array) $this->modelRepository);
$index = (string) new Index($this->meta->name, '', $paths, $objects, $ext);
Expand Down