Model Your APIs With AWS Smithy |
Written by Nikos Vaggalis | |||
Tuesday, 03 October 2023 | |||
Smithy is an open source project by AWS with which you can model your APIs, generate code and documentation for clients and servers, as well as other artifacts, in many programming languages. Smithy sprung out AWS's need of adopting a common format for its hundreds of APIs that would allow them to scale;most people associate scaling with handling server load but that also applies to APIs too. That is prevalent on AWS which supports SDKs in eleven programming languages and 270 services which get daily updated. That chaos had to be managed some way. The solution to the problem was the introduction of Smithy, an IDL (Interface Definition Language) alike OpenAPI that describes services and comprises of libraries that can generate code and other artifacts, but code generation being the main motivator for using Smithy. Smithy was initially developed for use in Amazon's own services and internal use but has been nevertheless released to the public as an open source project since 2019. As a matter of fact Smithy has now become the default choice at Amazon for modeling services. Why is that? First of all it's a protocol-agnostic IDL, meaning that it is designed to work with any programming language, describe services running in any environment, and work with any kind of transport or serialization format. Then, its code generation can be extended with custom traits and enable automatic API standards enforcement. Here is an example of a service defined with its Smithy's IDL own grammar and syntax: $version: "2" service Weather { resource City { From there on and in order to generate code you need the Java smithy gradle plugin or the cli. The new Python code generator comes with the following features:
To use the new generator there's two prerequisites. The first is Python of course of a minimum required version of 3. 11 and the second is Java 17, which is only required to build the generator. That aside, Smithy can also be used for Linting and Validation to ensure APIs adhere to the best practices and standard. It can generate OpenAPI models too. Compared to OpenAPI, Smithy appears to be a kind of abstract high-level language for defining apis, while OpenAPI is more like assembly that Smithy can be compiled to. On the project's road map there's releasing client code generators in every language supported by the aws sdks, a language server protocol implementation and the corresponding ide plugins for visual studio code and intellij. So if you want to take advantage of Amazon's experience in building and managing hundreds of services and SDKs in your own APIs, give Smithy a go.
More InformationSmithy Related ArticlesRedocly CLI - The Super Tool For API Management
To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.
Comments
or email your comment to: comments@i-programmer.info |
|||
Last Updated ( Tuesday, 03 October 2023 ) |