Skip to content

Commit c453d39

Browse files
authored
Merge pull request #218 from SOHELAHMED7/175-unable-to-reference-other-local-json-file
Resolve: Unable to reference other local json file
2 parents 2837673 + 993f1f0 commit c453d39

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

tests/IssueTest.php

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
use cebe\openapi\Reader;
4+
5+
class IssueTest extends \PHPUnit\Framework\TestCase
6+
{
7+
// https://github.com/cebe/php-openapi/issues/175
8+
public function test175UnableToReferenceOtherLocalJsonFile()
9+
{
10+
$openapi = Reader::readFromJsonFile(__DIR__.'/data/issue/175/spec.json');
11+
$this->assertInstanceOf(\cebe\openapi\SpecObjectInterface::class, $openapi);
12+
}
13+
}

tests/data/issue/175/401.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"description": "401 response",
3+
"content": {
4+
"application/json": {
5+
"schema": {
6+
"properties": {
7+
"message": {
8+
"type": "string"
9+
}
10+
},
11+
"required": [
12+
"message"
13+
]
14+
},
15+
"example": {
16+
"message": "Unauthenticated."
17+
}
18+
}
19+
}
20+
}

tests/data/issue/175/spec.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"openapi": "3.0.0",
3+
"info": {
4+
"title": "My API",
5+
"version": "1, 2"
6+
},
7+
"paths": {
8+
"/v1/users/profile": {
9+
"get": {
10+
"operationId": "V1GetUserProfile",
11+
"summary": "Returns the user profile",
12+
"responses": {
13+
"401": {
14+
"$ref": "./401.json"
15+
}
16+
}
17+
}
18+
}
19+
}
20+
}

0 commit comments

Comments
 (0)