From b43cab2445e494eee68407423b4a2df3cd9bfbe1 Mon Sep 17 00:00:00 2001 From: Ivan Moroz Date: Wed, 3 Jun 2026 16:33:50 +0300 Subject: [PATCH] CONV-301: Add converter schema endpoint Co-Authored-By: Claude Sonnet 4.6 --- routes/api.php | 1 + .../Api/V1/ConverterSchemaEndpointTest.php | 40 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 tests/Feature/Api/V1/ConverterSchemaEndpointTest.php diff --git a/routes/api.php b/routes/api.php index 68fb628..3bc5d62 100644 --- a/routes/api.php +++ b/routes/api.php @@ -23,5 +23,6 @@ } Route::get('/converters', [ConverterController::class, 'index'])->name('converters.index'); + Route::get('/converters/{source}/{target}/schema', [ConverterController::class, 'schema'])->name('converters.schema'); }); }); diff --git a/tests/Feature/Api/V1/ConverterSchemaEndpointTest.php b/tests/Feature/Api/V1/ConverterSchemaEndpointTest.php new file mode 100644 index 0000000..1858052 --- /dev/null +++ b/tests/Feature/Api/V1/ConverterSchemaEndpointTest.php @@ -0,0 +1,40 @@ +create(['plan' => Plan::Pro]); + $token = app(ApiKeyGenerator::class)->create($user, 'API')->plainToken; + + $this->withToken($token) + ->getJson('/api/v1/converters/png/jpg/schema') + ->assertOk() + ->assertJsonPath('data.source_format', 'png') + ->assertJsonPath('data.target_format', 'jpg') + ->assertJsonStructure([ + 'data' => [ + 'source_format', + 'target_format', + 'options', + ], + ]); +}); + +it('returns 422 for unsupported conversion pair', function () { + $user = User::factory()->create(['plan' => Plan::Pro]); + $token = app(ApiKeyGenerator::class)->create($user, 'API')->plainToken; + + $this->withToken($token) + ->getJson('/api/v1/converters/png/mp3/schema') + ->assertStatus(422) + ->assertJsonPath('error.code', 'unsupported_conversion'); +}); + +it('requires api key authentication to get converter schema', function () { + $this->getJson('/api/v1/converters/png/jpg/schema') + ->assertUnauthorized(); +});