Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ composer require radebatz/openapi-verifier
```
After that all required classes should be availabe in your project to add routing support.

Some features need further packages, such as a framework adapter or YAML support. They are listed
as suggestions, and `composer suggests radebatz/openapi-verifier` shows them.

## Usage
### Manual verification
The `VerifiesOpenApi` trait can be used directly and customized in 3 ways in order to provide the reqired OpenApi specifications:
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"suggest": {
"laravel/laravel": "A PHP framework",
"slim/slim": "A PHP framework",
"symfony/yaml": "To load YAML specifications",
"zircote/swagger-php": "OpenApi library to generate OpenAPI documentation from PHP annotations."
}
}
4 changes: 4 additions & 0 deletions src/OpenApiSpecificationLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ protected function resolveSpecification($specification)
$resolved = null;
if (is_string($specification)) {
if (false !== strpos($specification, '.yaml') || false !== strpos($specification, '.yml')) {
if (!class_exists(Yaml::class)) {
throw new \LogicException(sprintf('Unable to load specification "%s" as symfony/yaml is not installed. Try running "composer require symfony/yaml".', $specification));
}

try {
$resolved = (object) Yaml::parseFile($specification, Yaml::PARSE_OBJECT_FOR_MAP);
} catch (ParseException $parseException) {
Expand Down
Loading