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.
composer require solido/smithyuse 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.
}vendor/bin/solido-smithy \
--namespace=com.example.api \
--service-name=ExampleService \
--dto-namespace='App\DTO' \
--output=build/smithy/model.smithySolido\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