File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change 88use Illuminate \Console \Command ;
99use Mpociot \Reflection \DocBlock ;
1010use Illuminate \Support \Collection ;
11+ use Illuminate \Support \Facades \URL ;
1112use Mpociot \ApiDoc \Tools \Generator ;
1213use Mpociot \ApiDoc \Tools \RouteMatcher ;
1314use Mpociot \Documentarian \Documentarian ;
@@ -46,6 +47,7 @@ public function __construct(RouteMatcher $routeMatcher)
4647 */
4748 public function handle ()
4849 {
50+ URL ::forceRootUrl (config ('app.url ' ));
4951 $ usingDingoRouter = strtolower (config ('apidoc.router ' )) == 'dingo ' ;
5052 if ($ usingDingoRouter ) {
5153 $ routes = $ this ->routeMatcher ->getDingoRoutesToBeDocumented (config ('apidoc.routes ' ));
Original file line number Diff line number Diff line change 33namespace Mpociot \ApiDoc \Tests ;
44
55use ReflectionException ;
6+ use Illuminate \Support \Str ;
67use RecursiveIteratorIterator ;
78use RecursiveDirectoryIterator ;
89use Orchestra \Testbench \TestCase ;
@@ -230,6 +231,21 @@ public function generated_postman_collection_file_is_correct()
230231 $ this ->assertEquals ($ generatedCollection , $ fixtureCollection );
231232 }
232233
234+ /** @test */
235+ public function generated_postman_collection_domain_is_correct ()
236+ {
237+ $ domain = 'http://somedomain.test ' ;
238+ RouteFacade::get ('/api/test ' , TestController::class.'@withEndpointDescription ' );
239+
240+ config (['app.url ' => $ domain ]);
241+ config (['apidoc.routes.0.match.prefixes ' => ['api/* ' ]]);
242+ $ this ->artisan ('apidoc:generate ' );
243+
244+ $ generatedCollection = json_decode (file_get_contents (__DIR__ .'/../public/docs/collection.json ' ));
245+ $ endpointUrl = $ generatedCollection ->item [0 ]->item [0 ]->request ->url ;
246+ $ this ->assertTrue (Str::startsWith ($ endpointUrl , $ domain ));
247+ }
248+
233249 /** @test */
234250 public function generated_postman_collection_can_have_custom_url ()
235251 {
You can’t perform that action at this time.
0 commit comments