Smithy SDK code generators for Ruby and SDK core libraries.
WARNING: All interfaces are subject to change.
Generating an SDK for a Rails JSON API
- Create a new gradle project
- Add smithy to the plugins list (Note, you can find the latest plugin version at: https://plugins.gradle.org/plugin/software.amazon.smithy)
plugins {
id("software.amazon.smithy").version("0.6.0")
}
- Add the smithy-ruby-rails-codegen as a dependency:
dependencies {
implementation("software.amazon.smithy.ruby:smithy-ruby-rails-codegen:0.1.0")
}
-
Add your smithy model. under
<project_root>/model
. -
Create a smithy-build.json file that defines how Smithy should build your SDK. It must define a section under
plugins
forruby-codegen
. For reference see: rails json test smithy-build.json. -
Execute the gradle
build
task. This will generate the SDK from your model using the settings from your smithy-build.json file.
The generated SDK will be available under the build/smithyprojections/<project_name>//ruby-codegen folder.
This project is licensed under the Apache-2.0 License.
See CONTRIBUTING for more information.
Many Gradle issues can be fixed by stopping the daemon by running ./gradlew --stop
Codegen integration tests are written as ruby rspec tests (under smithy-ruby-codegentest/integration-specs). The gradle :smithy-ruby-codegen-test:build
target will create a sample_service_real
directory and copy the specs into it. From that directory, run rspec
(assuming you have required dependencies installed).
These tests run against the generated test sdk defined by the high-score model in the smithy-ruby-codegen-test project.
Hearth has a full suite of rspec tests which can be run from the hearth directory with: rspec
.
The sample-service
directory defines a rails service that can be run with rails s
. You can then test manually by adding hearth and the generated sdk client to your library path with:
irb -I 'hearth/lib' -I 'codegen/projections/high_score_service/lib'
And test with:
require 'high_score_service'
c = HighScoreService::Client.new(endpoint: 'http://127.0.0.1:3000')
c.get_high_score(id: '1')