smithy
smithy copied to clipboard
Example for Codegen Workflow
Hi Michael, the project looks very promising! We have been looking for an alternative to a Swagger-based cross-language codegen and API specification solution to replace our current version.
Do you have plans for a documentation of the codegen parts of this repo or is this out of scope for this project? Are you using this already, e.g. in the scope of the aws-sdk or are these tools?
Kind regards
Thanks for taking a look at Smithy!
Do you have plans for a documentation of the codegen parts of this repo or is this out of scope for this project?
Absolutely! It's still early for this project, but one of our goals is to implement code generators for multiple languages. We're in the process of getting some internal code bases in a state where we can publish them.
To help us prioritize: what kind of code generation are you interested in? Clients? Servers? Just the shapes by themselves? All of the above?
Are you using this already, e.g. in the scope of the aws-sdk or are these tools?
Yes, we use Smithy models inside of AWS today for several external AWS services and various internal services. We currently use Smithy to model services and then we convert Smithy models to other formats (for example, Swagger to integrate with API Gateway and our currently used JSON format to build SDKs). We've written code generators internally for generating clients for MQTT services, and we're working on getting those in a state that they can be open sourced. We're also starting the process of migrating some of the AWS SDKs to build from Smithy models directly, and ideally we will do this in a way so that they can also function as generic Smithy clients that can be used for non-AWS services.
Speaking of aws sdks, beyond https://awslabs.github.io/smithy/spec/aws-core.html, is there an eta on publishing a more complete set of aws service smith specs, similar to what the botocore project provides?
I'm really excited about this project and am looking for areas to contribute.
To help us prioritize: what kind of code generation are you interested in? Clients? Servers? Just the shapes by themselves? All of the above?
I would be looking for client generation mainly, we built an internal API spec to Client-Lib generator in golang ourselves but do not have the resources to maintain more than three language-specific client generators at the moment. The AWS SDK interfaces are mostly intriguingly consistent in their interface, and we ourselves rely heavily on them in dev-ops. So, we would appreciate being able to offer a similar unified interface and style to our API-clients at PhraseApp.
Also, it feels to be the right time to unify API specification, type exchange, and client generation in an extendable and consistent way (Protocol buffers, Graphql Schema, OAS etc.).
@softprops Glad you like the project! What are you looking to do with these models? Our goal is to continually publish Smithy models for every AWS service as features launch. We are targeting by the end of the year, but that isn't set in stone at this point. We are also planning to update the AWS SDKs to build directly from Smithy models and leverage the Smithy library code in this repo to make code generation even more consistent and easy to maintain across not only our officially supported SDKs, but also across community owned AWS SDKs.
@fredv Thanks for your feedback on the features you're looking for. You've identified one of the key problems that Smithy is trying to solve -- making it easy to automate the process of building very high quality and consistent SDKs across multiple languages.
Stay tuned. We'll post more information and tooling soon.
@mtdowling I'm specifically looking towards where this project is going and where the community driven Rustlang SDK project could go.
In addition, I've been involved with the Rustlang lambda runtime project over here as well as the Rustlang lambda project that came before it. In addition to service definitions, I'd love to have smithy definitions for lambda event types. At the moment, the best we have are event types based on scraping the code from the go sdk's which is not ideal as go and rust have different semantics. Some lambda events communicate the absence of values fields that return null and others that omit fields all together. That information doesn't translate well from go to rust. With smithy it seems I could bootstrap a new set of lambda event types, directly from a source of truth intended to be machine readable!
Hi there.
I was also looking for an example of a workflow to generate code, I'm interested in generating plain java classes to use with Lambda Handlers because the workflow of Smithy -> OpenAPI -> Java (OpenApi generates a bunch of classes and annotations that I don't need in Lambda) is suboptimal, to say the least.
I took a look at the AWS SDK for Java V2, they have a project for codegen, however, I didn't see any relationship with Smithy models there.
Do you have any example for a workflow to generate code for java or any direction you can guide me?
Thanks.
@ColadaFF Was able to strip away the smith-crt module and able to generate code. I think its the same
To help us prioritize: what kind of code generation are you interested in? Clients? Servers? Just the shapes by themselves? All of the above?
I am interested in all of the above. Personally I'd like a bit more documentation on what is additionally required in building a generator. I've been playing around a bit trying to generate a typescript client using smithy-typescript, and then diving into differences based on what I can see in the smithy-typescript and aws-sdk-js-v3 codebases.
For example, I tried using the former to generate an RPC client with AwsJson_1_1 traits, but the client serializers and deserializers are generated to always throw "protocol not supported errors". Diving in to the SDK code, there is a lot of additional code that seems supplementary to and/or diverged from what is in smithy-typescript.
I'm not expecting everything to be perfect from day-dot, but some additional documentation as to how generators are intended to be implemented would go a long a way to helping someone evaluate whether they want to invest time in smithy as opposed to any other similar tool. At the moment the barrier to entry feels very high.
I can see the value and I can appreciate overall interface of smithy, but atm it feels very difficult to get to a place where I can achieve practical benefits from it.
@atkawa7 and @ColadaFF, can you provide an example of how you generated the POJOs, or a link to more information?
I am also trying to figure out how to generate some client using the smithy models here: https://github.com/opensearch-project/opensearch-api-specification
From https://awslabs.github.io/smithy/2.0/implementations.html#client-code-generators I know that some of the other language specific code generators are still in development, but is there a way to generate Java code? If so, what is the config needed? From looking at the typescript readme it looks like we just need the right dependencies and config in the smith-build.json.
Can someone point me to an example or test if there is one for java client?
@AarjavP and @ColadaFF We currently don't have a code generator for Java, but it is something we are working on. You can see a list of code generators we have here: https://awslabs.github.io/smithy/2.0/implementations.html#client-code-generators
What are you looking to do with these models? Our goal is to continually publish Smithy models for every AWS service as features launch.
I'm not the OP, but I would love to have the Smithy models to use in writing our in-house AWS devops tooling. As a simple example (although I'm aware plenty of third-party solutions exist), I might build a simple "AWS inventory" script around the Smithy models by basically asking the models for "every type that has an ARN" and then finding the corresponding "list" endpoints and running them across my accounts.
I'm sure other use-cases will occur to me, but that's the one that indirectly lead me to discovering Smithy in the first place.
@tripplilley Checkout this https://github.com/boto/boto3/tree/develop/boto3/data
Checkout this https://github.com/boto/boto3/tree/develop/boto3/data
Yes, that's what I'm currently using 😄
Regarding Smithy models for AWS services, see https://github.com/awslabs/smithy/issues/1423.
Regarding code generation, see https://smithy.io/2.0/guides/building-codegen/index.html - for how to build a code generator https://smithy.io/2.0/guides/using-code-generation/index.html - for how to use a code generator https://github.com/smithy-lang/awesome-smithy - has list of our existing code generators, examples and other tools and resources
I think these resources addresses the questions here. If you have specific questions about any of these, feel free to open new issues.