Add an OpenAPI SDK generator for Hypervel Saloon
This adds hypervel/sdk-generator, a development dependency for building typed PHP clients from OpenAPI descriptions. The generated clients use Hypervel Saloon for requests, authentication, and pagination, and Hypervel Data for request and response objects. The generator runs from the command line without booting an application.
Generating a client
An SDK keeps a local copy of its OpenAPI description and a small sdk.php alongside its Composer manifest. The definition selects a source and the PHP namespace for the client. For example:
use Hypervel\SdkGenerator\SdkDefinition;
return SdkDefinition::make(
source: 'resources/openapi/openapi.yaml',
namespace: 'App\\Cloud',
);
Running vendor/bin/hypervel-sdk generate path/to/cloud writes the connector, resources, requests, and data objects under generated/. The definition can select operations, group them into resources, map provider types to application classes, and describe authentication, response handling, and pagination. Source corrections can live in the definition so the original provider description stays available for comparison.
The reader accepts local JSON and YAML files in Swagger 2.0 and OpenAPI 3.0 and 3.1. It also accepts OpenAPI 3.2 descriptions that use the supported 3.1 features and the QUERY method. Unsupported features in a selected operation are reported during generation.
Updating a client
Handwritten classes live in src/. A manifest in generated/ records the inputs and hashes of the files the generator owns. Regeneration checks those hashes before replacing output, so an unexpected edit, deletion, or extra file is reported before it can be overwritten.
Use generate --dry-run --diff to inspect a provider update, or generate --check in CI to detect drift without writing files.
Verification
The tests cover description loading, schema and operation compilation, rendering, CLI behavior, and output ownership. A committed example SDK exercises the generated client and its PHP types. The SDK generator suite, static analysis, and formatting checks passed locally. Regenerating the example produced no changes.
[!NOTE]
Add OpenAPI SDK generator for Hypervel Saloon
- Adds a full
sdk-generator component: OpenAPI source loading (JSON/YAML, Swagger 2.0 through OpenAPI 3.2), normalization, schema compilation, and generation of Saloon connectors, requests, resources, DTOs, enums, forms, authentication, OAuth, pagination, and wire helpers from an SdkDefinition file
- Includes a
hypervel-sdk CLI (generate command) with --dry-run, --diff, --check, and --only options, backed by a staged OutputManager that validates prior manifest ownership before replacing generated output
- Configuration is expressed through fluent builders (
SdkDefinition, OpenApiSource, TypeMapping, Authentication, Pagination, and others) that validate and freeze into immutable configurations
- Adds extensive test coverage across normalization, generation, rendering, output management, and the CLI, plus an
AnalysedSdk fixture used for end-to-end and PHPStan type checks
- Behavioral Change:
Connector::prefersUrlQuery() (default false) and UrlResolver::withQuery() change query merging so existing URL query pairs can win over connector defaults for designated fallback keys; withQueryParameters now replaces matching keys instead of appending
- Risk:
SdkGenerator::generate() reads $previousManifest before assigning it, causing an undefined-variable warning and a null value passed to stage() in SdkGenerator.php
Macroscope summarized efb019d.