This project demonstrates how to convert Smithy models to and from other formats such as OpenAPI.
This example demonstrates how the smithy-openapi
plugin can be used to convert a Smithy model into an OpenAPI specification.
The model used for this example is a slightly modified version of the Weather Service from the Smithy quickstart guide.
The smithy-openapi
plugin is applied to the model
by declaring the smithy-openapi package as a dependency
in the smithy-build.json
and adding the openapi
plugin to the openapi-conversion
projection
in the smithy-build.json
file. This will cause the openapi
plugin to run when the openapi-conversion
is built, generating an OpenAPI specification
as a build artifact of the openapi-conversion
projection.
Note: Smithy takes a different approach to modeling APIs from OpenAPI. Smithy is protocol agnostic, which means it focuses on the interfaces and abstractions that are provided to end-users rather than how the data is sent over the wire. OpenAPI, on the other hand only defines RESTful APIs. Because Smithy allows for a wider range of formats and a richer API model, conversions from Smithy to OpenAPI (and vice versa) may be lossy.
For more information on converting Smithy models to OpenAPI, including additional configuration options, see the guide here.
To use this example as a template run the following.
smithy init -t smithy-to-openapi