PHP code example of nova-horizons / laravel-openapi-sdk-generator

1. Go to this page and download the library: Download nova-horizons/laravel-openapi-sdk-generator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nova-horizons / laravel-openapi-sdk-generator example snippets


'id' => 'orbit',   // the key consumers use in extra.sdk-generator

'consumers' => [
    'space-app' => env('SDK_CONSUMER_SPACE_APP'),  // .env: SDK_CONSUMER_SPACE_APP=../space-app
],

$client = app(GizmoClient::class);   // configured from services.gizmo.url / .api_key

/** @var Collection<int, Widget> $widgets */
$widgets = $client->widgets()->searchWidgets(q: 'coupler', limit: 25);

$widgets->first()->recWidgetSN;   // int — hydrated from __rec_WidgetSN

new WidgetUpdate(widgetName: 'Torsion Coupler');  // sends {"widget_name": "Torsion Coupler"}
new WidgetUpdate(binLocation: null);              // sends {"bin_location": null} — clears the field
new WidgetUpdate();                               // sends {} — touches nothing

Http::fake([OrbitFake::GET_BEACON => Http::response(OrbitFake::beacon(['active' => false]))]);

#[OA\SecurityScheme(securityScheme: 'appApiKey', type: 'apiKey', in: 'header', name: 'X-Api-Key')]

spec.json → SpecLoader (cebe/php-openapi, refs preserved) → Mapper → IR → Emitters (nette/php-generator) → your formatter
json
"extra": {
    "sdk-generator": {
        "orbit": {
            "namespace": "App\\Sdk\\Orbit",
            "out": "app/Sdk/Orbit",
            "client": "OrbitClient",
            "allow": ["missing-error-schema"],
            "format": "vendor/bin/sail php vendor/bin/php-cs-fixer fix {out}"
        }
    }
}