OpenAPISpecWriterTest.php 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. <?php
  2. namespace Knuckles\Scribe\Tests\Unit;
  3. use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts;
  4. use Faker\Factory;
  5. use Illuminate\Support\Arr;
  6. use Knuckles\Camel\Camel;
  7. use Knuckles\Camel\Output\OutputEndpointData;
  8. use Knuckles\Scribe\Tools\DocumentationConfig;
  9. use Knuckles\Scribe\Writing\OpenAPISpecWriter;
  10. use PHPUnit\Framework\TestCase;
  11. /**
  12. * See https://swagger.io/specification/
  13. */
  14. class OpenAPISpecWriterTest extends TestCase
  15. {
  16. use ArraySubsetAsserts;
  17. protected $config = [
  18. 'title' => 'My Testy Testes API',
  19. 'description' => 'All about testy testes.',
  20. 'base_url' => 'http://api.api.dev',
  21. ];
  22. /** @test */
  23. public function follows_correct_spec_structure()
  24. {
  25. $endpointData1 = $this->createMockEndpointData();
  26. $endpointData2 = $this->createMockEndpointData();
  27. $groups = [$this->createGroup([$endpointData1, $endpointData2])];
  28. $results = $this->generate($groups);
  29. $this->assertEquals(OpenAPISpecWriter::SPEC_VERSION, $results['openapi']);
  30. $this->assertEquals($this->config['title'], $results['info']['title']);
  31. $this->assertEquals($this->config['description'], $results['info']['description']);
  32. $this->assertNotEmpty($results['info']['version']);
  33. $this->assertEquals($this->config['base_url'], $results['servers'][0]['url']);
  34. $this->assertIsArray($results['paths']);
  35. $this->assertGreaterThan(0, count($results['paths']));
  36. }
  37. /** @test */
  38. public function adds_endpoints_correctly_as_operations_under_paths()
  39. {
  40. $endpointData1 = $this->createMockEndpointData(['uri' => 'path1', 'httpMethods' => ['GET']]);
  41. $endpointData2 = $this->createMockEndpointData(['uri' => 'path1', 'httpMethods' => ['POST']]);
  42. $endpointData3 = $this->createMockEndpointData(['uri' => 'path1/path2']);
  43. $groups = [$this->createGroup([$endpointData1, $endpointData2, $endpointData3])];
  44. $results = $this->generate($groups);
  45. $this->assertIsArray($results['paths']);
  46. $this->assertCount(2, $results['paths']);
  47. $this->assertCount(2, $results['paths']['/path1']);
  48. $this->assertCount(1, $results['paths']['/path1/path2']);
  49. $this->assertArrayHasKey('get', $results['paths']['/path1']);
  50. $this->assertArrayHasKey('post', $results['paths']['/path1']);
  51. $this->assertArrayHasKey(strtolower($endpointData3->httpMethods[0]), $results['paths']['/path1/path2']);
  52. collect([$endpointData1, $endpointData2, $endpointData3])->each(function (OutputEndpointData $endpoint) use ($groups, $results) {
  53. $endpointSpec = $results['paths']['/' . $endpoint->uri][strtolower($endpoint->httpMethods[0])];
  54. $tags = $endpointSpec['tags'];
  55. $containingGroup = Arr::first($groups, function ($group) use ($endpoint) {
  56. return Camel::doesGroupContainEndpoint($group, $endpoint);
  57. });
  58. $this->assertEquals([$containingGroup['name']], $tags);
  59. $this->assertEquals($endpoint->metadata->title, $endpointSpec['summary']);
  60. $this->assertEquals($endpoint->metadata->description, $endpointSpec['description']);
  61. });
  62. }
  63. /** @test */
  64. public function adds_authentication_details_correctly_as_security_info()
  65. {
  66. $endpointData1 = $this->createMockEndpointData(['uri' => 'path1', 'httpMethods' => ['GET'], 'metadata.authenticated' => true]);
  67. $endpointData2 = $this->createMockEndpointData(['uri' => 'path1', 'httpMethods' => ['POST'], 'metadata.authenticated' => false]);
  68. $groups = [$this->createGroup([$endpointData1, $endpointData2])];
  69. $extraInfo = "When stuck trying to authenticate, have a coffee!";
  70. $config = array_merge($this->config, [
  71. 'auth' => [
  72. 'enabled' => true,
  73. 'in' => 'bearer',
  74. 'extra_info' => $extraInfo,
  75. ],
  76. ]);
  77. $writer = new OpenAPISpecWriter(new DocumentationConfig($config));
  78. $results = $writer->generateSpecContent($groups);
  79. $this->assertCount(1, $results['components']['securitySchemes']);
  80. $this->assertArrayHasKey('default', $results['components']['securitySchemes']);
  81. $this->assertEquals('http', $results['components']['securitySchemes']['default']['type']);
  82. $this->assertEquals('bearer', $results['components']['securitySchemes']['default']['scheme']);
  83. $this->assertEquals($extraInfo, $results['components']['securitySchemes']['default']['description']);
  84. $this->assertCount(1, $results['security']);
  85. $this->assertCount(1, $results['security'][0]);
  86. $this->assertArrayHasKey('default', $results['security'][0]);
  87. $this->assertArrayNotHasKey('security', $results['paths']['/path1']['get']);
  88. $this->assertArrayHasKey('security', $results['paths']['/path1']['post']);
  89. $this->assertCount(0, $results['paths']['/path1']['post']['security']);
  90. // Next try: auth with a query parameter
  91. $config = array_merge($this->config, [
  92. 'auth' => [
  93. 'enabled' => true,
  94. 'in' => 'query',
  95. 'name' => 'token',
  96. 'extra_info' => $extraInfo,
  97. ],
  98. ]);
  99. $writer = new OpenAPISpecWriter(new DocumentationConfig($config));
  100. $results = $writer->generateSpecContent($groups);
  101. $this->assertCount(1, $results['components']['securitySchemes']);
  102. $this->assertArrayHasKey('default', $results['components']['securitySchemes']);
  103. $this->assertEquals('apiKey', $results['components']['securitySchemes']['default']['type']);
  104. $this->assertEquals($extraInfo, $results['components']['securitySchemes']['default']['description']);
  105. $this->assertEquals($config['auth']['name'], $results['components']['securitySchemes']['default']['name']);
  106. $this->assertEquals('query', $results['components']['securitySchemes']['default']['in']);
  107. $this->assertCount(1, $results['security']);
  108. $this->assertCount(1, $results['security'][0]);
  109. $this->assertArrayHasKey('default', $results['security'][0]);
  110. $this->assertArrayNotHasKey('security', $results['paths']['/path1']['get']);
  111. $this->assertArrayHasKey('security', $results['paths']['/path1']['post']);
  112. $this->assertCount(0, $results['paths']['/path1']['post']['security']);
  113. }
  114. /** @test */
  115. public function adds_url_parameters_correctly_as_parameters_on_path_item_object()
  116. {
  117. $endpointData1 = $this->createMockEndpointData([
  118. 'httpMethods' => ['POST'],
  119. 'uri' => 'path1/{param}/{optionalParam?}',
  120. 'urlParameters.param' => [
  121. 'description' => 'Something',
  122. 'required' => true,
  123. 'example' => 56,
  124. 'type' => 'integer',
  125. 'name' => 'param',
  126. ],
  127. 'urlParameters.optionalParam' => [
  128. 'description' => 'Another',
  129. 'required' => false,
  130. 'example' => '69',
  131. 'type' => 'string',
  132. 'name' => 'optionalParam',
  133. ],
  134. ]);
  135. $endpointData2 = $this->createMockEndpointData(['uri' => 'path1', 'httpMethods' => ['POST']]);
  136. $groups = [$this->createGroup([$endpointData1, $endpointData2])];
  137. $results = $this->generate($groups);
  138. $this->assertArrayNotHasKey('parameters', $results['paths']['/path1']);
  139. $this->assertCount(2, $results['paths']['/path1/{param}/{optionalParam}']['parameters']);
  140. $this->assertEquals([
  141. 'in' => 'path',
  142. 'required' => true,
  143. 'name' => 'param',
  144. 'description' => 'Something',
  145. 'example' => 56,
  146. 'schema' => ['type' => 'integer'],
  147. ], $results['paths']['/path1/{param}/{optionalParam}']['parameters'][0]);
  148. $this->assertEquals([
  149. 'in' => 'path',
  150. 'required' => true,
  151. 'name' => 'optionalParam',
  152. 'description' => 'Optional parameter. Another',
  153. 'examples' => [
  154. 'omitted' => ['summary' => 'When the value is omitted', 'value' => ''],
  155. 'present' => [
  156. 'summary' => 'When the value is present', 'value' => '69'],
  157. ],
  158. 'schema' => ['type' => 'string'],
  159. ], $results['paths']['/path1/{param}/{optionalParam}']['parameters'][1]);
  160. }
  161. /** @test */
  162. public function adds_headers_correctly_as_parameters_on_operation_object()
  163. {
  164. $endpointData1 = $this->createMockEndpointData(['httpMethods' => ['POST'], 'uri' => 'path1', 'headers.Extra-Header' => 'Some-example']);
  165. $endpointData2 = $this->createMockEndpointData(['uri' => 'path1', 'httpMethods' => ['GET'], 'headers' => []]);
  166. $groups = [$this->createGroup([$endpointData1, $endpointData2])];
  167. $results = $this->generate($groups);
  168. $this->assertEquals([], $results['paths']['/path1']['get']['parameters']);
  169. $this->assertCount(1, $results['paths']['/path1']['post']['parameters']);
  170. $this->assertEquals([
  171. 'in' => 'header',
  172. 'name' => 'Extra-Header',
  173. 'description' => '',
  174. 'example' => 'Some-example',
  175. 'schema' => ['type' => 'string'],
  176. ], $results['paths']['/path1']['post']['parameters'][0]);
  177. }
  178. /** @test */
  179. public function adds_query_parameters_correctly_as_parameters_on_operation_object()
  180. {
  181. $endpointData1 = $this->createMockEndpointData([
  182. 'httpMethods' => ['GET'],
  183. 'uri' => '/path1',
  184. 'headers' => [], // Emptying headers so it doesn't interfere with parameters object
  185. 'queryParameters' => [
  186. 'param' => [
  187. 'description' => 'A query param',
  188. 'required' => false,
  189. 'example' => 'hahoho',
  190. 'type' => 'string',
  191. 'name' => 'param',
  192. ],
  193. ],
  194. ]);
  195. $endpointData2 = $this->createMockEndpointData(['headers' => [], 'httpMethods' => ['POST'], 'uri' => '/path1',]);
  196. $groups = [$this->createGroup([$endpointData1, $endpointData2])];
  197. $results = $this->generate($groups);
  198. $this->assertEquals([], $results['paths']['/path1']['post']['parameters']);
  199. $this->assertArrayHasKey('parameters', $results['paths']['/path1']['get']);
  200. $this->assertCount(1, $results['paths']['/path1']['get']['parameters']);
  201. $this->assertEquals([
  202. 'in' => 'query',
  203. 'required' => false,
  204. 'name' => 'param',
  205. 'description' => 'A query param',
  206. 'example' => 'hahoho',
  207. 'schema' => [
  208. 'type' => 'string',
  209. 'description' => 'A query param',
  210. 'example' => 'hahoho',
  211. ],
  212. ], $results['paths']['/path1']['get']['parameters'][0]);
  213. }
  214. /** @test */
  215. public function adds_body_parameters_correctly_as_requestBody_on_operation_object()
  216. {
  217. $endpointData1 = $this->createMockEndpointData([
  218. 'httpMethods' => ['POST'],
  219. 'uri' => '/path1',
  220. 'bodyParameters' => [
  221. 'stringParam' => [
  222. 'name' => 'stringParam',
  223. 'description' => 'String param',
  224. 'required' => false,
  225. 'example' => 'hahoho',
  226. 'type' => 'string',
  227. ],
  228. 'integerParam' => [
  229. 'name' => 'integerParam',
  230. 'description' => 'Integer param',
  231. 'required' => true,
  232. 'example' => 99,
  233. 'type' => 'integer',
  234. ],
  235. 'booleanParam' => [
  236. 'name' => 'booleanParam',
  237. 'description' => 'Boolean param',
  238. 'required' => true,
  239. 'example' => false,
  240. 'type' => 'boolean',
  241. ],
  242. 'objectParam' => [
  243. 'name' => 'objectParam',
  244. 'description' => 'Object param',
  245. 'required' => false,
  246. 'example' => [],
  247. 'type' => 'object',
  248. ],
  249. 'objectParam.field' => [
  250. 'name' => 'objectParam.field',
  251. 'description' => 'Object param field',
  252. 'required' => false,
  253. 'example' => 119.0,
  254. 'type' => 'number',
  255. ],
  256. ],
  257. ]);
  258. $endpointData2 = $this->createMockEndpointData(['httpMethods' => ['GET'], 'uri' => '/path1']);
  259. $endpointData3 = $this->createMockEndpointData([
  260. 'httpMethods' => ['PUT'],
  261. 'uri' => '/path2',
  262. 'bodyParameters' => [
  263. 'fileParam' => [
  264. 'name' => 'fileParam',
  265. 'description' => 'File param',
  266. 'required' => false,
  267. 'example' => null,
  268. 'type' => 'file',
  269. ],
  270. 'numberArrayParam' => [
  271. 'name' => 'numberArrayParam',
  272. 'description' => 'Number array param',
  273. 'required' => false,
  274. 'example' => [186.9],
  275. 'type' => 'number[]',
  276. ],
  277. 'objectArrayParam' => [
  278. 'name' => 'objectArrayParam',
  279. 'description' => 'Object array param',
  280. 'required' => false,
  281. 'example' => [[]],
  282. 'type' => 'object[]',
  283. ],
  284. 'objectArrayParam[].field1' => [
  285. 'name' => 'objectArrayParam[].field1',
  286. 'description' => 'Object array param first field',
  287. 'required' => true,
  288. 'example' => ["hello"],
  289. 'type' => 'string[]',
  290. ],
  291. 'objectArrayParam[].field2' => [
  292. 'name' => 'objectArrayParam[].field2',
  293. 'description' => '',
  294. 'required' => false,
  295. 'example' => "hi",
  296. 'type' => 'string',
  297. ],
  298. ],
  299. ]);
  300. $groups = [$this->createGroup([$endpointData1, $endpointData2, $endpointData3])];
  301. $results = $this->generate($groups);
  302. $this->assertArrayNotHasKey('requestBody', $results['paths']['/path1']['get']);
  303. $this->assertArrayHasKey('requestBody', $results['paths']['/path1']['post']);
  304. $this->assertEquals([
  305. 'required' => true,
  306. 'content' => [
  307. 'application/json' => [
  308. 'schema' => [
  309. 'type' => 'object',
  310. 'properties' => [
  311. 'stringParam' => [
  312. 'description' => 'String param',
  313. 'example' => 'hahoho',
  314. 'type' => 'string',
  315. ],
  316. 'booleanParam' => [
  317. 'description' => 'Boolean param',
  318. 'example' => false,
  319. 'type' => 'boolean',
  320. ],
  321. 'integerParam' => [
  322. 'description' => 'Integer param',
  323. 'example' => 99,
  324. 'type' => 'integer',
  325. ],
  326. 'objectParam' => [
  327. 'description' => 'Object param',
  328. 'example' => [],
  329. 'type' => 'object',
  330. 'properties' => [
  331. 'field' => [
  332. 'description' => 'Object param field',
  333. 'example' => 119.0,
  334. 'type' => 'number',
  335. ],
  336. ],
  337. ],
  338. ],
  339. 'required' => [
  340. 'integerParam',
  341. 'booleanParam',
  342. ],
  343. ],
  344. ],
  345. ],
  346. ], $results['paths']['/path1']['post']['requestBody']);
  347. $this->assertEquals([
  348. 'required' => false,
  349. 'content' => [
  350. 'multipart/form-data' => [
  351. 'schema' => [
  352. 'type' => 'object',
  353. 'properties' => [
  354. 'fileParam' => [
  355. 'description' => 'File param',
  356. 'type' => 'string',
  357. 'format' => 'binary',
  358. ],
  359. 'numberArrayParam' => [
  360. 'description' => 'Number array param',
  361. 'example' => [186.9],
  362. 'type' => 'array',
  363. 'items' => [
  364. 'type' => 'number',
  365. ],
  366. ],
  367. 'objectArrayParam' => [
  368. 'description' => 'Object array param',
  369. 'example' => [[]],
  370. 'type' => 'array',
  371. 'items' => [
  372. 'type' => 'object',
  373. 'required' => ['field1'],
  374. 'properties' => [
  375. 'field1' => [
  376. 'type' => 'array',
  377. 'items' => [
  378. 'type' => 'string',
  379. ],
  380. 'description' => 'Object array param first field',
  381. 'example' => ["hello"],
  382. ],
  383. 'field2' => [
  384. 'type' => 'string',
  385. 'description' => '',
  386. 'example' => "hi",
  387. ],
  388. ],
  389. ],
  390. ],
  391. ],
  392. ],
  393. ],
  394. ],
  395. ], $results['paths']['/path2']['put']['requestBody']);
  396. }
  397. /** @test */
  398. public function adds_responses_correctly_as_responses_on_operation_object()
  399. {
  400. $endpointData1 = $this->createMockEndpointData([
  401. 'httpMethods' => ['POST'],
  402. 'uri' => '/path1',
  403. 'responses' => [
  404. [
  405. 'status' => 204,
  406. 'description' => 'Successfully updated.',
  407. 'content' => '{"this": "should be ignored"}',
  408. ],
  409. [
  410. 'status' => 201,
  411. 'description' => '',
  412. 'content' => '{"this": "shouldn\'t be ignored", "and this": "too", "sub level 0": { "sub level 1 key 1": "sl0_sl1k1", "sub level 1 key 2": [ { "sub level 2 key 1": "sl0_sl1k2_sl2k1", "sub level 2 key 2": { "sub level 3 key 1": "sl0_sl1k2_sl2k2_sl3k1" } } ], "sub level 1 key 3": { "sub level 2 key 1": "sl0_sl1k3_sl2k2", "sub level 2 key 2": { "sub level 3 key 1": "sl0_sl1k3_sl2k2_sl3k1", "sub level 3 key null": null, "sub level 3 key integer": 99 } } } }',
  413. ],
  414. ],
  415. 'responseFields' => [
  416. 'and this' => [
  417. 'name' => 'and this',
  418. 'type' => 'string',
  419. 'description' => 'Parameter description, ha!',
  420. ],
  421. 'sub level 0.sub level 1 key 3.sub level 2 key 1'=> [
  422. 'description' => 'This is description of nested object',
  423. ]
  424. ],
  425. ]);
  426. $endpointData2 = $this->createMockEndpointData([
  427. 'httpMethods' => ['PUT'],
  428. 'uri' => '/path2',
  429. 'responses' => [
  430. [
  431. 'status' => 200,
  432. 'description' => '',
  433. 'content' => '<<binary>> The cropped image',
  434. ],
  435. ],
  436. ]);
  437. $groups = [$this->createGroup([$endpointData1, $endpointData2])];
  438. $results = $this->generate($groups);
  439. $this->assertCount(2, $results['paths']['/path1']['post']['responses']);
  440. $this->assertArraySubset([
  441. '204' => [
  442. 'description' => 'Successfully updated.',
  443. ],
  444. '201' => [
  445. 'content' => [
  446. 'application/json' => [
  447. 'schema' => [
  448. 'type' => 'object',
  449. 'properties' => [
  450. 'this' => [
  451. 'example' => "shouldn't be ignored",
  452. 'type' => 'string',
  453. ],
  454. 'and this' => [
  455. 'description' => 'Parameter description, ha!',
  456. 'example' => "too",
  457. 'type' => 'string',
  458. ],
  459. 'sub level 0' => [
  460. 'type' => 'object',
  461. 'properties' => [
  462. 'sub level 1 key 1' => [
  463. 'type' => 'string',
  464. 'example' => 'sl0_sl1k1'
  465. ],
  466. 'sub level 1 key 2' => [
  467. 'type' => 'array',
  468. 'example' => [
  469. [
  470. 'sub level 2 key 1' => 'sl0_sl1k2_sl2k1',
  471. 'sub level 2 key 2' => [
  472. 'sub level 3 key 1' => 'sl0_sl1k2_sl2k2_sl3k1'
  473. ]
  474. ]
  475. ],
  476. 'items' => [
  477. 'type' => 'object'
  478. ]
  479. ],
  480. 'sub level 1 key 3' => [
  481. 'type' => 'object',
  482. 'properties' => [
  483. 'sub level 2 key 1' => [
  484. 'type' => 'string',
  485. 'example' => 'sl0_sl1k3_sl2k2',
  486. 'description' => 'This is description of nested object'
  487. ],
  488. 'sub level 2 key 2' => [
  489. 'type' => 'object',
  490. 'properties' => [
  491. 'sub level 3 key 1' => [
  492. 'type' => 'string',
  493. 'example' => 'sl0_sl1k3_sl2k2_sl3k1'
  494. ],
  495. 'sub level 3 key null' => [
  496. 'type' => 'string',
  497. 'example' => null
  498. ],
  499. 'sub level 3 key integer' => [
  500. 'type' => 'integer',
  501. 'example' => 99
  502. ]
  503. ]
  504. ]
  505. ]
  506. ]
  507. ]
  508. ]
  509. ],
  510. ],
  511. ],
  512. ],
  513. ],
  514. ], $results['paths']['/path1']['post']['responses']);
  515. $this->assertCount(1, $results['paths']['/path2']['put']['responses']);
  516. $this->assertEquals([
  517. '200' => [
  518. 'description' => 'The cropped image',
  519. 'content' => [
  520. 'application/octet-stream' => [
  521. 'schema' => [
  522. 'type' => 'string',
  523. 'format' => 'binary',
  524. ],
  525. ],
  526. ],
  527. ],
  528. ], $results['paths']['/path2']['put']['responses']);
  529. }
  530. protected function createMockEndpointData(array $custom = []): OutputEndpointData
  531. {
  532. $faker = Factory::create();
  533. $path = '/' . $faker->word();
  534. $data = [
  535. 'uri' => $path,
  536. 'httpMethods' => $faker->randomElements(['GET', 'POST', 'PUT', 'PATCH', 'DELETE'], 1),
  537. 'headers' => [
  538. 'Content-Type' => 'application/json',
  539. ],
  540. 'metadata' => [
  541. 'title' => $faker->sentence(),
  542. 'description' => $faker->randomElement([$faker->sentence(), '']),
  543. 'authenticated' => $faker->boolean(),
  544. ],
  545. 'urlParameters' => [], // Should be set by caller (along with custom path)
  546. 'queryParameters' => [],
  547. 'bodyParameters' => [],
  548. 'responses' => [
  549. [
  550. 'status' => 200,
  551. 'content' => '{"random": "json"}',
  552. 'description' => 'Okayy',
  553. ],
  554. ],
  555. 'responseFields' => [],
  556. ];
  557. foreach ($custom as $key => $value) {
  558. data_set($data, $key, $value);
  559. }
  560. return OutputEndpointData::create($data);
  561. }
  562. protected function createGroup(array $endpoints)
  563. {
  564. $faker = Factory::create();
  565. return [
  566. 'description' => '',
  567. 'name' => $faker->randomElement(['Endpoints', 'Group A', 'Group B']),
  568. 'endpoints' => $endpoints,
  569. ];
  570. }
  571. protected function generate(array $groups): array
  572. {
  573. $writer = new OpenAPISpecWriter(new DocumentationConfig($this->config));
  574. return $writer->generateSpecContent($groups);
  575. }
  576. }