Skip to content

Commit 06ff709

Browse files
committed
added test for reading inline JSON in YAML
1 parent 0a974ba commit 06ff709

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

tests/ReaderTest.php

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,40 @@ private function assertApiContent(\cebe\openapi\spec\OpenApi $openapi)
8989
$this->assertEquals("1.0.0", $openapi->info->version);
9090
}
9191

92-
92+
/**
93+
* @see https://github.com/symfony/symfony/issues/34805
94+
*/
95+
public function testSymfonyYamlBugHunt()
96+
{
97+
$openApiFile = __DIR__ . '/../vendor/oai/openapi-specification/examples/v3.0/uspto.yaml';
98+
$openapi = \cebe\openapi\Reader::readFromYamlFile($openApiFile);
99+
100+
$inlineYamlExample = $openapi->paths['/']->get->responses['200']->content['application/json']->example;
101+
$this->assertInternalType('array', $inlineYamlExample);
102+
$expectedArray = json_decode(<<<JSON
103+
{
104+
"total": 2,
105+
"apis": [
106+
{
107+
"apiKey": "oa_citations",
108+
"apiVersionNumber": "v1",
109+
"apiUrl": "https://developer.uspto.gov/ds-api/oa_citations/v1/fields",
110+
"apiDocumentationUrl": "https://developer.uspto.gov/ds-api-docs/index.html?url=https://developer.uspto.gov/ds-api/swagger/docs/oa_citations.json"
111+
},
112+
{
113+
"apiKey": "cancer_moonshot",
114+
"apiVersionNumber": "v1",
115+
"apiUrl": "https://developer.uspto.gov/ds-api/cancer_moonshot/v1/fields",
116+
"apiDocumentationUrl": "https://developer.uspto.gov/ds-api-docs/index.html?url=https://developer.uspto.gov/ds-api/swagger/docs/cancer_moonshot.json"
117+
}
118+
]
119+
}
120+
JSON
121+
, true);
122+
$this->assertEquals($expectedArray, $inlineYamlExample);
123+
}
124+
125+
93126
// TODO test invalid JSON
94127
// TODO test invalid YAML
95128
}

0 commit comments

Comments
 (0)