Move URL parameters down to the endpoint level for the OpenAPI specification. This can help improve some http clients ability to import and render the spec correctly.
Example Routes
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Api\v1\TruckController;
/**
* Search Trucks
*
*/
Route::get('trucks', [TruckController::class, 'search'])->name('demo.search');
/**
* View Truck
*
* @urlParam id string Unique identifier for the truck
*/
Route::get('trucks/{id}', [TruckController::class, 'view'])->name('demo.view');
BEFORE
openapi.yaml
paths:
/trucks: ...
'/trucks/{id}':
get:
summary: 'View a Truck'
operationId: getTrucksId
description: 'View a specific Truck'
parameters: []
responses: ...
tags: ...
security: []
parameters:
-
in: path
name: id
description: 'The ID of the truck.'
example: provident
required: true
schema:
type: string
HTTP Client
AFTER
openapi.yaml
paths:
/trucks: ...
'/trucks/{id}':
get:
summary: 'View a Truck'
operationId: getTrucksId
description: 'View a specific Truck'
parameters:
-
in: path
name: id
description: 'The ID of the truck.'
example: trk123
required: true
schema:
type: string
responses: ...
tags: ...
security: []
Move URL parameters down to the endpoint level for the OpenAPI specification. This can help improve some http clients ability to import and render the spec correctly.
Example Routes
BEFORE
openapi.yaml
HTTP Client
AFTER
openapi.yaml
HTTP Client