Skip to content

Commit 0d2f288

Browse files
authored
Merge pull request #15 from JeroenVanOort/correctly-handle-ref
Correctly handle $ref
2 parents 2fcaa37 + 9b47786 commit 0d2f288

File tree

3 files changed

+9
-18
lines changed

3 files changed

+9
-18
lines changed

src/ValidatesOpenApiSpec.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ public function getOpenApiValidatorBuilder(): ValidatorBuilder
4141
$specType = $this->getSpecFileType();
4242

4343
if ($specType === 'json') {
44-
$this->openApiValidatorBuilder = (new ValidatorBuilder())->fromJson($this->getOpenApiSpec());
44+
$this->openApiValidatorBuilder = (new ValidatorBuilder())->fromJsonFile($this->getOpenApiSpecPath());
4545
} elseif ($specType === 'yaml') {
46-
$this->openApiValidatorBuilder = (new ValidatorBuilder())->fromYaml($this->getOpenApiSpec());
46+
$this->openApiValidatorBuilder = (new ValidatorBuilder())->fromYamlFile($this->getOpenApiSpecPath());
4747
} else {
4848
throw new UnknownParserForFileTypeException("Unknown parser for file type {$specType}");
4949
}
@@ -185,16 +185,6 @@ protected function shouldSkipRequestValidation(): bool
185185
return false;
186186
}
187187

188-
/**
189-
* Gets the open api spec (contents).
190-
*
191-
* @return string
192-
*/
193-
protected function getOpenApiSpec(): string
194-
{
195-
return File::get($this->getOpenApiSpecPath());
196-
}
197-
198188
/**
199189
* Gets the openapi.yaml path.
200190
*/

tests/fixtures/OpenAPI.yaml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,7 @@ paths:
7373
'200':
7474
description: OK
7575
/private:
76-
get:
77-
responses:
78-
'200':
79-
description: OK
80-
security:
81-
- Basic: []
76+
$ref: 'sub-spec.yaml'
8277
components:
8378
securitySchemes:
8479
Basic:

tests/fixtures/sub-spec.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
get:
2+
responses:
3+
'200':
4+
description: OK
5+
security:
6+
- Basic: []

0 commit comments

Comments
 (0)