From 6b464f024cb37cada6bc513396670279812721cb Mon Sep 17 00:00:00 2001 From: Anne Jan Brouwer Date: Sat, 25 Jun 2022 00:35:11 +0200 Subject: [PATCH] Less dumb v2 (#118) * Swagger up * Publish swagger * API redirect and cleanup * API double prefix * Revert the stupid * v2 * Testing v2 * More v2 --- app/Http/Controllers/MchController.php | 2 +- app/Providers/RouteServiceProvider.php | 2 +- tests/Feature/Mch20222Test.php | 30 +++++++++++++------------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/app/Http/Controllers/MchController.php b/app/Http/Controllers/MchController.php index 9c4bafc..db0aee3 100644 --- a/app/Http/Controllers/MchController.php +++ b/app/Http/Controllers/MchController.php @@ -19,7 +19,7 @@ class MchController extends Controller * List the available devices. * * @OA\Get( - * path="/devices", + * path="/mch2022/devices", * tags={"MCH2022"}, * @OA\Response(response="default",ref="#/components/responses/undocumented") * ) diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 91f3984..5893381 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -72,7 +72,7 @@ protected function mapWebRoutes() ->group(base_path('routes/weather.php')); Route::middleware('web') ->namespace($this->namespace) - ->prefix('mch2022') + ->prefix('v2') ->group(base_path('routes/mch2022.php')); } } diff --git a/tests/Feature/Mch20222Test.php b/tests/Feature/Mch20222Test.php index 82b798b..95d6e94 100644 --- a/tests/Feature/Mch20222Test.php +++ b/tests/Feature/Mch20222Test.php @@ -26,7 +26,7 @@ class Mch20222Test extends TestCase */ public function testMchDevices(): void { - $response = $this->json('GET', '/mch2022/devices'); + $response = $this->json('GET', '/v2/devices'); $response->assertStatus(200) ->assertExactJson([]); @@ -36,7 +36,7 @@ public function testMchDevices(): void /** @var Badge $badge */ $badge = Badge::factory()->create(); - $response = $this->json('GET', '/mch2022/devices'); + $response = $this->json('GET', '/v2/devices'); $response->assertStatus(200) ->assertExactJson([ [ @@ -51,7 +51,7 @@ public function testMchDevices(): void */ public function testMchDeviceTypes(): void { - $response = $this->json('GET', '/mch2022/random_device/types'); + $response = $this->json('GET', '/v2/random_device/types'); $response->assertStatus(404); /** @var User $user */ @@ -60,7 +60,7 @@ public function testMchDeviceTypes(): void /** @var Badge $badge */ $badge = Badge::factory()->create(); - $response = $this->json('GET', '/mch2022/' . $badge->slug . '/types'); + $response = $this->json('GET', '/v2/' . $badge->slug . '/types'); $response->assertStatus(200) ->assertExactJson([ [ @@ -83,7 +83,7 @@ public function testMchDeviceTypes(): void */ public function testMchCategories(): void { - $response = $this->json('GET', '/mch2022/iets/esp32/categories'); + $response = $this->json('GET', '/v2/iets/esp32/categories'); $response->assertStatus(404); /** @var User $user */ @@ -92,7 +92,7 @@ public function testMchCategories(): void /** @var Badge $badge */ $badge = Badge::factory()->create(); - $response = $this->json('GET', '/mch2022/' . $badge->slug . '/esp32/categories'); + $response = $this->json('GET', '/v2/' . $badge->slug . '/esp32/categories'); $response->assertStatus(200) ->assertExactJson([]); @@ -105,11 +105,11 @@ public function testMchCategories(): void /** @var Category $category */ $category = $version->project->category()->first(); - $response = $this->json('GET', '/mch2022/' . $badge->slug . '/esp32/categories'); + $response = $this->json('GET', '/v2/' . $badge->slug . '/esp32/categories'); $response->assertStatus(200) ->assertExactJson([]); - $response = $this->json('GET', '/mch2022/' . $badge->slug . '/python/categories'); + $response = $this->json('GET', '/v2/' . $badge->slug . '/python/categories'); $response->assertStatus(200) ->assertExactJson([ [ @@ -125,7 +125,7 @@ public function testMchCategories(): void */ public function testMchApps(): void { - $response = $this->json('GET', '/mch2022/iets/app/some_app'); + $response = $this->json('GET', '/v2/iets/app/some_app'); $response->assertStatus(404); /** @var User $user */ @@ -142,12 +142,12 @@ public function testMchApps(): void /** @var Category $category */ $category = $version->project->category()->first(); - $response = $this->json('GET', '/mch2022/' . $badge->slug . '/python/' . $category->slug . '/iets'); + $response = $this->json('GET', '/v2/' . $badge->slug . '/python/' . $category->slug . '/iets'); $response->assertStatus(404); $response = $this->json( 'GET', - '/mch2022/' . $badge->slug . '/python/' . $category->slug . '/' . $version->project->slug + '/v2/' . $badge->slug . '/python/' . $category->slug . '/' . $version->project->slug ); $response->assertStatus(200) ->assertJson([]); @@ -155,7 +155,7 @@ public function testMchApps(): void $file = File::factory()->create(['version_id' => $version->id]); $response = $this->json( 'GET', - '/mch2022/' . $badge->slug . '/python/' . $category->slug . '/' . $version->project->slug + '/v2/' . $badge->slug . '/python/' . $category->slug . '/' . $version->project->slug ); $response->assertStatus(200) ->assertJson([ @@ -168,7 +168,7 @@ public function testMchApps(): void [ 'name' => $file->name, 'url' => url( - 'mch2022/' . $badge->slug . '/python/' . $category->slug . '/' . + 'v2/' . $badge->slug . '/python/' . $category->slug . '/' . $version->project->slug . '/' . $file->name ), 'size' => $file->size_of_content @@ -199,7 +199,7 @@ public function testMchFile(): void $response = $this->json( 'GET', - '/mch2022/' . $badge->slug . '/python/' . $category->slug . '/' . + '/v2/' . $badge->slug . '/python/' . $category->slug . '/' . $version->project->slug . '/random.txt' ); $response->assertStatus(404) @@ -207,7 +207,7 @@ public function testMchFile(): void $response = $this->json( 'GET', - '/mch2022/' . $badge->slug . '/python/' . $category->slug . '/' . + '/v2/' . $badge->slug . '/python/' . $category->slug . '/' . $version->project->slug . '/' . $file->name ); $response->assertStatus(200)