Skip to content

Commit

Permalink
Merge pull request #15 from JeroenVanOort/correctly-handle-ref
Browse files Browse the repository at this point in the history
Correctly handle $ref
  • Loading branch information
luisdalmolin authored Dec 5, 2023
2 parents 2fcaa37 + 9b47786 commit 0d2f288
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 18 deletions.
14 changes: 2 additions & 12 deletions src/ValidatesOpenApiSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public function getOpenApiValidatorBuilder(): ValidatorBuilder
$specType = $this->getSpecFileType();

if ($specType === 'json') {
$this->openApiValidatorBuilder = (new ValidatorBuilder())->fromJson($this->getOpenApiSpec());
$this->openApiValidatorBuilder = (new ValidatorBuilder())->fromJsonFile($this->getOpenApiSpecPath());
} elseif ($specType === 'yaml') {
$this->openApiValidatorBuilder = (new ValidatorBuilder())->fromYaml($this->getOpenApiSpec());
$this->openApiValidatorBuilder = (new ValidatorBuilder())->fromYamlFile($this->getOpenApiSpecPath());
} else {
throw new UnknownParserForFileTypeException("Unknown parser for file type {$specType}");
}
Expand Down Expand Up @@ -185,16 +185,6 @@ protected function shouldSkipRequestValidation(): bool
return false;
}

/**
* Gets the open api spec (contents).
*
* @return string
*/
protected function getOpenApiSpec(): string
{
return File::get($this->getOpenApiSpecPath());
}

/**
* Gets the openapi.yaml path.
*/
Expand Down
7 changes: 1 addition & 6 deletions tests/fixtures/OpenAPI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,7 @@ paths:
'200':
description: OK
/private:
get:
responses:
'200':
description: OK
security:
- Basic: []
$ref: 'sub-spec.yaml'
components:
securitySchemes:
Basic:
Expand Down
6 changes: 6 additions & 0 deletions tests/fixtures/sub-spec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
get:
responses:
'200':
description: OK
security:
- Basic: []

0 comments on commit 0d2f288

Please sign in to comment.