solido / smithy
Smithy model generation from Solido DTO metadata.
dev-main
2026-09-05 08:43 UTC
Requires
- php: ^8.4
- friendsofphp/proxy-manager-lts: ^1.0
- kcs/class-finder: ^0.6
- solido/common: ^0.5
- solido/dto-management: ^0.5
Requires (Dev)
- kcs/serializer: ^5.0
- phpunit/phpunit: ^11.0 || ^12.0
- roave/security-advisories: dev-master
- solido/php-coding-standards: dev-master
- symfony/routing: ^7.4 || ^8.0
- symfony/validator: ^7.4 || ^8.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-09-05 08:44:06 UTC
README
Generates Smithy models from Solido DTO metadata.
This package is currently experimental. It provides package-owned Smithy metadata attributes, a DTO metadata extractor, a small intermediate API model, optional Symfony route operation extraction, and a deterministic Smithy IDL renderer.
Installation
composer require solido/smithy
Usage
use Solido\Smithy\Extractor\DtoMetadataExtractor; use Solido\Smithy\GeneratorConfig; use Solido\Smithy\Renderer\SmithyIdlRenderer; use Solido\Smithy\SmithyGenerator; use Solido\Smithy\Type\TypeOverride; $generator = new SmithyGenerator( new DtoMetadataExtractor($resolver), new SmithyIdlRenderer(), ); $smithy = $generator->generate(new GeneratorConfig( namespace: 'com.example.api', serviceName: 'ExampleService', dtoNamespaces: ['App\\DTO'], typeOverrides: [ TypeOverride::type(App\ValueObject\UserId::class, 'String'), TypeOverride::member(App\DTO\v1\v1_0\User::class, 'id', 'smithy.api#String'), ], ));
Use generateResult() when diagnostics or the intermediate model are needed:
$result = $generator->generateResult(new GeneratorConfig( namespace: 'com.example.api', serviceName: 'ExampleService', dtoNamespaces: ['App\\DTO'], )); foreach ($result->diagnostics() as $diagnostic) { // Surface warnings in CI or in an application command. }
CLI
vendor/bin/solido-smithy \
--namespace=com.example.api \
--service-name=ExampleService \
--dto-namespace='App\DTO' \
--output=build/smithy/model.smithy
Supported Metadata
Solido\Smithy\Attribute\HttpHeaderSolido\Smithy\Attribute\HttpLabelSolido\Smithy\Attribute\HttpPayloadSolido\Smithy\Attribute\IgnoreInputSolido\Smithy\Attribute\IgnoreOutputSolido\Smithy\Attribute\InputNameSolido\Smithy\Attribute\ListOutputSolido\Smithy\Attribute\MemberNameSolido\Smithy\Attribute\SolidoList- type overrides configured with
Solido\Smithy\Type\TypeOverride - PHPDoc list types such as
Project[], rendered as Smithy list shapes when the element class can be resolved - Symfony
#[Route]attributes, whensymfony/routingis installed - KCS serializer
SerializedName,Exclude, andVirtualPropertyattributes, whenkcs/serializeris installed - Symfony validator
NotBlankandNotNullconstraints, whensymfony/validatoris installed