### Initialize Smithy Kotlin Quickstart Project Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/languages/kotlin/quickstart.rst Use the Smithy CLI to initialize the quickstart example template and navigate into the project directory. ```sh smithy init -t smithy-kotlin-quickstart && cd smithy-kotlin-quickstart ``` -------------------------------- ### Server Output Example Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/tutorials/full-stack-tutorial.rst This is an example of the expected output when the server starts and begins handling requests. ```text Started server on port 3001... handling orders... ``` -------------------------------- ### Install Smithy CLI using Scoop (Windows) Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/guides/smithy-cli/cli_installation.rst Recommended installation method for Windows using the Scoop package manager. Adds the Smithy Scoop Bucket and installs the smithy-cli. ```powershell scoop bucket add smithy-lang https://github.com/smithy-lang/scoop-bucket; \ scoop install smithy-lang/smithy-cli ``` -------------------------------- ### Initialize Smithy Project from Example Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/guides/gradle-plugin/index.rst Copies a Smithy Gradle plugin example into your workspace using the Smithy CLI. Replace `` and `` with your desired values. ```text smithy init -t -o --url https://github.com/smithy-lang/smithy-gradle-plugin ``` -------------------------------- ### Create Smithy Quickstart Directory Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/quickstart.rst Use this command to set up the necessary directory structure and create the initial weather model file for the Smithy quickstart. ```text mkdir -p smithy-quickstart/model \ && touch smithy-quickstart/model/weather.smithy \ && cd smithy-quickstart ``` -------------------------------- ### OpenAPI Example for Response Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/guides/model-translations/converting-to-openapi.rst This OpenAPI JSON snippet shows the conversion of the Smithy @examples trait for operation output. It defines an example for the successful response, including summary, description, and the example value. ```json "responses": { "200": { "description": "FooOperation response", "content": { "application/json": { "examples": { "FooOperation_example1": { "summary": "valid example", "description": "valid example doc", "value": { "baz": "5678" } } } } } } } ``` -------------------------------- ### Start Server Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/languages/typescript/quickstart.rst Navigate to the server directory and start the server application. This may initially fail due to missing operation implementations. ```sh cd server && yarn setup && yarn start ``` -------------------------------- ### List Available Smithy Gradle Examples Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/guides/gradle-plugin/index.rst Lists all examples available in the Smithy Gradle plugins repository using the Smithy CLI. ```text smithy init --list --url https://github.com/smithy-lang/smithy-gradle-plugin ``` -------------------------------- ### Install Smithy Dependencies Source: https://github.com/smithy-lang/smithy/blob/main/docs/README.md Installs the required dependencies and local modules for building the Smithy documentation. Ensure Python 3 is installed. ```bash make install ``` -------------------------------- ### Example smithy-build.json Configuration Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/guides/smithy-build-json.rst This example demonstrates a typical smithy-build.json configuration, including version, output directory, sources, imports, Maven dependencies, projections with transforms and plugins, and global plugins. ```json { "version": "1.0", "outputDirectory": "build/output", "sources": ["model"], "imports": ["foo.json", "some/directory"], "maven": { "dependencies": [ "software.amazon.smithy:smithy-aws-traits:__smithy_version__" ] }, "projections": { "my-abstract-projection": { "abstract": true }, "projection-name": { "imports": ["projection-specific-imports/"], "transforms": [ { "name": "excludeShapesByTag", "args": { "tags": ["internal", "beta", "..."] } }, { "name": "excludeShapesByTrait", "args": { "traits": ["internal"] } } ], "plugins": { "plugin-name": { "plugin-config": "value" }, "run::custom-artifact-name": { "command": ["my-codegenerator", "--debug"] }, "...": {} } } }, "plugins": { "plugin-name": { "plugin-config": "value" }, "...": {} } } ``` -------------------------------- ### httpPrefixHeaders Input Example Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/spec/http-bindings.rst Example input data for an operation using the httpPrefixHeaders trait. ```json { "headers": { "first": "hi", "second": "there" } } ``` -------------------------------- ### Smithy @examples Trait for Operation Input Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/guides/model-translations/converting-to-openapi.rst This Smithy model snippet shows how to apply the @examples trait to an operation, defining example input and output values for testing and documentation purposes. ```smithy apply FooOperation @examples( [ { title: "valid example", documentation: "valid example doc", input: { bar: "1234" }, output: { baz: "5678" }, } ] ) ``` -------------------------------- ### Examples Trait for Operations Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/spec/documentation-traits.rst Provides example inputs and outputs for operations, including success and error cases. The 'allowConstraintErrors' flag can be used with error examples. ```smithy @readonly operation MyOperation { input: MyOperationInput output: MyOperationOutput errors: [MyOperationError] } apply MyOperation @examples([ { title: "Invoke MyOperation" input: { tags: ["foo", "baz", "bar"] } output: { status: "PENDING" } } { title: "Another example for MyOperation" input: { foo: "baz" } output: { status: "PENDING" } } { title: "Error example for MyOperation" input: { foo: "!" } error: { shapeId: MyOperationError content: { message: "Invalid 'foo'. Special character not allowed." } }, allowConstraintErrors: true } ]) ``` -------------------------------- ### Client Terminal Output Example Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/languages/java/quickstart.rst Example console output from the client application showing order creation and retrieval. Order IDs will vary. ```sh INFO: Created request with id = f526ddca-105c-4f89-a754-a10ea542c84b INFO: Got order with id = f526ddca-105c-4f89-a754-a10ea542c84b INFO: Waiting for order to complete.... INFO: Completed Order :GetOrderOutput[id=f526ddca-105c-4f89-a754-a10ea542c84b, coffee ``` -------------------------------- ### HTTP Query Parameters Input Example Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/spec/http-bindings.rst Example JSON input for the PutThing operation, illustrating how tags are provided. ```json { "thingId": "realId", "tags": { "thingId": "fakeId", "otherTag": "value" } } ``` -------------------------------- ### Extract and run Smithy CLI installer (Windows x64) Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/guides/smithy-cli/cli_installation.rst Extracts the downloaded Smithy CLI archive and runs the installation script on Windows x64. Requires administrator privileges or a custom installation path. ```powershell Expand-Archive smithy-install\|windows|.zip -DestinationPath smithy-install\; \ Move-Item -Path smithy-install\|windows|\* -Destination smithy-install\smithy; \ smithy-install\smithy\install ``` -------------------------------- ### Run Smithy CLI Installer for MacOS (Manual) Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/guides/smithy-cli/cli_installation.rst Execute the Smithy CLI installer script after downloading and extracting the necessary files. This command typically requires sudo privileges to install in the default location. ```sh sudo smithy-install/smithy/install ``` -------------------------------- ### OpenAPI Example for Request Body Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/guides/model-translations/converting-to-openapi.rst This OpenAPI JSON snippet illustrates how the Smithy @examples trait for operation input is converted. It defines an example for the request body, including summary, description, and the example value. ```json "paths": { "/": { "get": { "operationId": "FooOperation", "requestBody": { "content": { "application/json": { "examples": { "FooOperation_example1": { "summary": "valid example", "description": "valid example doc", "value": { "bar": "1234" } } } } } } ``` -------------------------------- ### Bootstrap Full Stack Application Project Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/tutorials/full-stack-tutorial.rst Initializes a new full-stack application project from a Smithy example repository. ```sh smithy init -t full-stack-application ``` -------------------------------- ### Example ARNs from Various Services Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/aws/aws-core.rst Provides concrete examples of ARN formats used by different AWS services. ```none // Elastic Beanstalk application version arn:aws:elasticbeanstalk:us-east-1:123456789012:environment/My App/MyEnvironment ``` ```none // IAM user name arn:aws:iam::123456789012:user/David ``` ```none // Amazon RDS instance used for tagging arn:aws:rds:eu-west-1:123456789012:db:mysql-db ``` ```none // Object in an Amazon S3 bucket arn:aws:s3:::my_corporate_bucket/exampleobject.png ``` -------------------------------- ### Smithy CLI Project Structure Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/quickstart.rst Example directory layout for a Smithy project initialized with the CLI. ```text . ├── smithy-build.json └── model └── weather.smithy ``` -------------------------------- ### Gradle Project Structure Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/quickstart.rst Example directory layout for a Smithy project initialized with Gradle. ```text . ├── build.gradle.kts ├── smithy-build.json └── model └── weather.smithy ``` -------------------------------- ### Example Model with Mixins Source: https://github.com/smithy-lang/smithy/blob/main/designs/mixins.md Provides a concrete example of a structure using a mixin, illustrating member inheritance. ```smithy @mixin structure PaginatedInput { nextToken: String, pageSize: Integer } structure ListSomethingInput with [PaginatedInput] { nameFilter: String } ``` -------------------------------- ### Install bats-core Source: https://github.com/smithy-lang/smithy/blob/main/smithy-cli/configuration/README.md Installs the `bats-core` testing framework using Homebrew. This is a prerequisite for running shell script tests. ```bash #!/bin/bash brew install bats-core ``` -------------------------------- ### Resource Mixin Example Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/spec/mixins.rst Demonstrates how to define and apply a resource mixin. Mixins allow for the composition of resource properties. ```smithy @mixin @internal resource MixinResource {} resource MixedResource with [MixinResource] {} ``` -------------------------------- ### smithy-build.json Configuration Example Source: https://github.com/smithy-lang/smithy/blob/main/smithy-trait-codegen/README.md Example configuration for the trait-codegen plugin in smithy-build.json, specifying package, namespace, header, and excludeTags. ```json { "version": "1.0", "plugins": { "trait-codegen": { "package": "com.example.traits", "namespace": "com.example.traits", "header": ["Copyright Example Corp"], "excludeTags": ["internal"] } } } ``` -------------------------------- ### Example GetMenu Response Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/tutorials/full-stack-tutorial.rst An example JSON response for the GetMenu operation, showing a list of coffee items with their types and descriptions. ```json { "items": [ { "type": "LATTE", "description": "A creamier, milk-based drink made with espresso" } ] } ``` -------------------------------- ### Example Input Structure (Day 1) Source: https://github.com/smithy-lang/smithy/blob/main/designs/defaults-and-model-evolution.md Illustrates a structure with a required title member before model evolution. ```smithy structure Message { @required title: String message: String } ``` -------------------------------- ### Mixin Composition Example Source: https://github.com/smithy-lang/smithy/blob/main/designs/mixins.md Demonstrates how mixins can be composed, where one mixin uses another mixin. ```smithy @mixin structure MixinA { a: String } @mixin structure MixinB with [MixinA] { b: String } structure C with [MixinB] { c: String } ``` -------------------------------- ### Run Server Application Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/languages/java/quickstart.rst Start the updated server application. Ensure the server is running before testing the new operation. ```sh ./gradlew server:run ``` -------------------------------- ### Install shellcheck Source: https://github.com/smithy-lang/smithy/blob/main/smithy-cli/configuration/README.md Installs the `shellcheck` static analysis tool using Homebrew. This tool helps identify potential issues in shell scripts. ```bash #!/bin/bash brew install shellcheck ``` -------------------------------- ### Smithy Waiter Acceptor Example Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/additional-specs/waiters.rst An example of a Smithy waiter configuration with success and failure acceptors. This snippet demonstrates how to define states and matchers for waiter transitions. ```smithy @waitable( ResourceRunning: { documentation: "Waits for the resource to be running" acceptors: [ { state: "failure" matcher: { output: { path: "State" expected: "Stopped" comparator: "stringEquals" } } } { state: "success" matcher: { output: { path: "State" expected: "Running" comparator: "stringEquals" } } } // other acceptors... ] } ) operation GetResource { input: GetResourceInput output: GetResourceOutput } ``` -------------------------------- ### Effective Documentation Example Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/spec/documentation-traits.rst Illustrates how effective documentation is resolved for shapes and members based on trait inheritance. ```smithy structure Foo { @documentation("Member documentation") baz: Baz bar: Baz qux: String } @documentation("Shape documentation") string Baz ``` -------------------------------- ### Smithy IDL Model Example Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/spec/idl.rst This example demonstrates a Smithy IDL model file with all three sections: Control, Metadata, and Shape. It includes a version directive, metadata, a namespace definition, a use statement, and a structure definition. ```smithy // (1) Control section $version: "2" // (2) Metadata section metadata foo = "bar" // (3) Shape section namespace smithy.example use smithy.other.namespace#MyString structure MyStructure { @required foo: MyString } ``` -------------------------------- ### Flatten Mixins in Smithy Model (Example) Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/guides/building-codegen/using-the-semantic-model.rst Illustrates a Smithy model with mixins before and after flattening. ```smithy @mixin structure HasUsername { @required username: String } structure UserData with [HasUserName] { isAdmin: Boolean } ``` ```smithy structure UserData with [HasUserName] { @required username: String isAdmin: Boolean } ``` -------------------------------- ### Initialize Smithy Project from Template Source: https://github.com/smithy-lang/smithy/blob/main/smithy-cli/src/it/resources/software/amazon/smithy/cli/projects/smithy-templates/getting-started-example/README.md Use this command to create a new Smithy project based on the 'quickstart-cli' template. Ensure the Smithy CLI is installed. ```bash smithy init --template quickstart-cli ``` -------------------------------- ### Define a GET operation with a URI Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/spec/http-bindings.rst This example shows a read-only GET operation with a URI pattern that includes a label for binding to an input member. The `readonly` trait indicates that the operation does not have side effects. ```smithy @readonly @http(method: "GET", uri: "/foo/{baz}") operation GetService { output: GetServiceOutput } ``` -------------------------------- ### Validate Lifecycle Operation Naming with EmitEachSelector Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/spec/model-validation.rst Checks if lifecycle 'read' or 'delete' operations start with 'Get' or 'Delete' respectively. ```smithy $version: "2" metadata validators = [ { name: "EmitEachSelector" id: "LifecycleGetName" message: "Lifecycle 'read' operation shape names should start with 'Get'" configuration: { ``` -------------------------------- ### Require Examples on Operations Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/guides/model-validation-examples.rst Checks for examples on all operation shapes. Ensures that the `@@examples` trait is applied to each operation. ```smithy { name: "EmitEachSelector", id: "MissingOperationExamples", configuration: { messageTemplate: """ Operation `@{id|name}` is missing examples. Add the `@@examples` \ trait to this operation. """, selector: "operation :not([trait|examples])" } } ``` -------------------------------- ### Clean up installation files (Windows) Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/guides/smithy-cli/cli_installation.rst Removes downloaded installation files after a successful manual installation on Windows. ```powershell rm -r -force smithy-install\ ``` -------------------------------- ### Initialize Smithy Java Project Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/languages/java/quickstart.rst Use the Smithy CLI to initialize a new Java quickstart project template and navigate into the project directory. ```sh smithy init -t smithy-java-quickstart && cd smithy-java-quickstart ``` -------------------------------- ### Initialize Project Dependencies Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/tutorials/full-stack-tutorial.rst Runs the make init command to set up project dependencies and configurations. ```sh make init ``` -------------------------------- ### Initialize Smithy Project with CLI Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/quickstart.rst Initializes a new Smithy project using the Smithy CLI. ```bash smithy init -o ``` -------------------------------- ### Clean up Smithy CLI installation files Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/guides/smithy-cli/cli_installation.rst Remove the downloaded installation files and directories after successfully installing the Smithy CLI. This helps to free up disk space. ```sh rm -rf smithy-install/ ``` -------------------------------- ### Initialize Smithy TypeScript Project Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/languages/typescript/quickstart.rst Use the Smithy CLI to initialize a new project from the quickstart template and navigate into the project directory. ```sh smithy init -t smithy-typescript-quickstart && cd smithy-typescript-quickstart ``` -------------------------------- ### Install Smithy CLI using Homebrew on MacOS Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/guides/smithy-cli/cli_installation.rst Use this command to install the Smithy CLI via Homebrew. Ensure you have Homebrew installed and have tapped the official Smithy Homebrew Tap. ```sh brew tap smithy-lang/tap && brew install smithy-cli ``` -------------------------------- ### Serve Smithy Documentation Locally Source: https://github.com/smithy-lang/smithy/blob/main/docs/README.md Serves the built Smithy documentation locally for preview. This allows you to view the documentation as it would appear online. ```bash make serve ``` -------------------------------- ### JSON Event Example Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/aws/amazon-eventstream.rst An example of a JSON event message with specified content type. ```text :content-type: application/json {"foo":"bar"} ``` -------------------------------- ### Initialize Smithy Project for OpenAPI Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/guides/model-translations/converting-to-openapi.rst Initialize a new Smithy project with a template designed for OpenAPI conversion. ```bash smithy init -t smithy-to-openapi -o ``` -------------------------------- ### Build Server SDK and Implementation Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/tutorials/full-stack-tutorial.rst Use the 'make build-server' command to generate the server SDK and compile the server implementation. This command orchestrates the code generation and build processes. ```sh make build-server ``` -------------------------------- ### Unmodeled Error Event Example Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/aws/amazon-eventstream.rst An example of an unmodeled error event message with error code and message. ```text :message-type: error :error-code: InternalError :error-message: An internal server error occurred. ``` -------------------------------- ### Binary Blob Event Example Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/aws/amazon-eventstream.rst An example of a binary blob event message with specified content type. ```text :message-type: event :event-type: blob :content-type: application/octet-stream IkFyYml0cmFyeSBiaW5hcnkiCg== ``` -------------------------------- ### Download and extract Smithy CLI (Linux ARM) Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/guides/smithy-cli/cli_installation.rst Manual installation steps for Linux ARM, involving downloading a zip archive, extracting it, and moving files to the correct directory. ```sh mkdir -p smithy-install/smithy && \ curl -L |release-uri|/|linux-arm|.zip -o smithy-install/|linux-arm|.zip && \ unzip -qo smithy-install/|linux-arm|.zip -d smithy-install && \ mv smithy-install/|linux-arm|/* smithy-install/smithy ``` -------------------------------- ### Plain Text Event Example Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/aws/amazon-eventstream.rst An example of a plain text event message with specified content type. ```text :message-type: event :event-type: string :content-type: text/plain Arbitrary text ``` -------------------------------- ### Initialize Smithy Gradle Project Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/languages/java/client/generating-clients.rst Use the `smithy init` command to create a new Smithy Gradle project. This sets up the basic project structure. ```sh smithy init -t quickstart-gradle ``` -------------------------------- ### Deprecated Parameter Example Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/additional-specs/rules-engine/specification.rst Example of a parameter marked as deprecated, including a message and the date since deprecation. ```json { "parameters": { "linkId": { "type": "string", "deprecated": { "message": "This feature has been deprecated, and requests are now directed towards a global endpoint.", "since": "2020-07-02" }, } } } ``` -------------------------------- ### Download Smithy CLI archive (Windows x64) Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/guides/smithy-cli/cli_installation.rst Manual installation step for Windows x64, downloading the zip archive of the Smithy CLI. ```powershell New-Item -Type Directory -Path smithy-install\smithy -Force; \ Invoke-WebRequest -Uri |release-uri|/|windows|.zip \ -OutFile smithy-install\|windows|.zip ``` -------------------------------- ### Unix Start Script Logic Source: https://github.com/smithy-lang/smithy/blob/main/smithy-cli/configuration/unixStartScript.txt This script resolves symbolic links to find the application's home directory and sets up necessary environment variables. It includes logic for handling different operating systems and configuring JVM options. ```shell #!/usr/bin/env sh # Resolve links: $0 may be a link app_path=$0 # Need this for daisy-chained symlinks. while APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path [ -h "$app_path" ] do ls=$( ls -ld "$app_path" ) link=${ls#*' -> '} case $link in #( /*) app_path=$link ;; *) app_path=$APP_HOME$link ;; esac done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} APP_HOME=$( cd "${APP_HOME:-./}${appHomeRelativePath}" && pwd -P ) || exit # Add default JVM options here. You can also use JAVA_OPTS and ${optsEnvironmentVar} to pass JVM options to this script. DEFAULT_JVM_OPTS=${defaultJvmOpts} # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false case "$( uname )" in #( CYGWIN* ) cygwin=true ;; Darwin* ) darwin=true ;; MSYS* | MINGW* ) msys=true ;; NONSTOP* ) nonstop=true ;; esac CLASSPATH="$APP_HOME/lib/*" JAVA_HOME="$APP_HOME" JAVACMD="$JAVA_HOME/bin/java" # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) # Now convert the arguments - kludge to limit ourselves to /bin/sh for arg do if case $arg in #( -*) false ;; # don't mess with options /?*) t=${arg#/} t=/ [ -e "$t" ] ;; *) false ;; esac then arg=$( cygpath --path --ignore --mixed "$arg" ) fi # Roll the args list around exactly as many times as the number of # args, so each arg winds up back in the position where it started, but # possibly modified. # # NB: a `for` loop captures its iteration list before it begins, so # changing the positional parameters here affects neither the number of # iterations, nor the values presented in `arg`. shift # remove old arg set -- "$@" "$arg" # push replacement arg done fi # Escape application args save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\ /' \\\\/" ; done echo " " } APP_ARGS=$(save "$@") # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $JAVA_TOOL_OPTIONS $DEFAULT_JVM_OPTS $CDS_JVM_OPTS $JAVA_OPTS $${optsEnvironmentVar} <% if ( appNameSystemProperty ) { %>""-D${appNameSystemProperty}=${APP_BASE_NAME}"" <% } %>-classpath """$CLASSPATH""" ${mainClassName} "$APP_ARGS" # Unset this environment variable before calling Java to prevent it from appearing in stderr. # Instead, the value stored in this variable is passed in to the command in the previous line manually. unset JAVA_TOOL_OPTIONS <% if ( System.properties['BADASS_RUN_IN_BIN_DIR'] ) { %>cd "$APP_HOME/bin" && <% } %>exec "$JAVACMD" "$@" ``` -------------------------------- ### HTTP Request Example Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/aws/amazon-eventstream.rst Example HTTP request targeting Kinesis's GetRecordStream API with a JSON payload. ```http POST / HTTP/1.1 X-Amz-Target: Kinesis_20131202.GetRecordStream Content-Length: 224 {"ShardIterator":"..."} ``` -------------------------------- ### Build and Run Server Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/tutorials/full-stack-tutorial.rst This shell command builds and runs the server application. Ensure the server is running before testing client interactions. ```sh make run-server ``` -------------------------------- ### HTTP Request with Various Query Parameters Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/spec/http-bindings.rst Example HTTP request demonstrating different query parameter scenarios, including keys with and without values. ```http POST /things?thingId=realId&otherTag=true&anotherTag&lastTag= ``` -------------------------------- ### Modeled Error Event Example Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/aws/amazon-eventstream.rst An example of a modeled error event message with exception type and JSON content. ```text :message-type: exception :exception-type: modeledError :content-type: application/json {"message":"..."} ``` -------------------------------- ### Configure a Smithy-Build Codegen Plugin Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/guides/building-codegen/overview-and-concepts.rst Example smithy-build.json file to configure a codegen plugin for generating a client in a hypothetical Foo language. ```json { "version": "1.0", "plugins": { "foo-client-codegen": { "service": "smithy.example#Weather", "package": "com.example.weather", "packageVersion": "0.0.1", "edition": "2022" } } } ``` -------------------------------- ### Required Parameter Example Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/additional-specs/rules-engine/specification.rst Example of a parameter marked as required. Parameters with defaults must also be marked as required. ```json { "parameters": { "linkId": { "type": "string", "documentation": "The identifier of the link to target.", "required": true } } } ``` -------------------------------- ### Build Smithy Project Source: https://github.com/smithy-lang/smithy/blob/main/smithy-cli/src/it/resources/software/amazon/smithy/cli/projects/smithy-templates/getting-started-example/README.md Execute this command from the root of your Smithy project directory to build the project. Requires the Smithy CLI. ```bash smithy build ``` -------------------------------- ### Start Coffee Shop Server Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/languages/typescript/quickstart.rst Start the coffee shop server and its order handling process. The server will run on port 8888. ```sh yarn setup && yarn start ``` -------------------------------- ### Using @input and @output Traits for Operation Input/Output Source: https://github.com/smithy-lang/smithy/blob/main/designs/operation-input-output-and-unit-types.md This example demonstrates the correct application of the `@input` and `@output` traits to specialize structures for operation input and output. Shapes marked with these traits can only be referenced by a single operation. ```smithy operation GetFoo { input: GetFooInput, output: GetFooOutput } @input structure GetFooInput {} @output structure GetFooOutput {} ``` -------------------------------- ### Sample 'run' Plugin Shell Script Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/guides/smithy-build-json.rst This shell script demonstrates how to process command-line arguments, access Smithy-provided environment variables, and handle standard input within a 'run' plugin execution. ```bash #!/bin/sh # Command line arguments are provided. echo "--arg: $2" # Print out the provided environment variables. echo "SMITHY_ROOT_DIR: ${SMITHY_ROOT_DIR}" echo "SMITHY_PLUGIN_DIR: ${SMITHY_PLUGIN_DIR}" echo "SMITHY_PROJECTION_NAME: ${SMITHY_PROJECTION_NAME}" echo "SMITHY_ARTIFACT_NAME: ${SMITHY_ARTIFACT_NAME}" echo "SMITHY_INCLUDES_PRELUDE: ${SMITHY_INCLUDES_PRELUDE}" # Copy the model from stdin and write it to copy-model.json. # The process is run in the appropriate working directory for the # plugin ID's artifact name. cat >> copy-model.json ``` -------------------------------- ### Project Structure with Gradle (Groovy) Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/guides/using-code-generation/generating-a-client.rst This illustrates the project structure when using Gradle with Groovy DSL for a Smithy project. ```text . └── smithy ├── build ├── build.gradle ├── model └── smithy-build.json ``` -------------------------------- ### Example Rule Set Parameters Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/additional-specs/rules-engine/parameters.rst Illustrates the structure of a rule set with defined parameters, including their types and documentation. These parameters can be bound to values using various traits. ```json { "version": "1.0", "serviceId": "example", "parameters": { "linkId": { "type": "string", "documentation": "The identifier of the link to target." }, "previewEndpoint": { "type": "boolean", "documentation": "Whether the client should target the service's preview endpoint." ``` -------------------------------- ### Smithy Build Configuration Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/quickstart.rst Example smithy-build.json file for configuring the Smithy build process. Specifies the version of the build file specification. ```json { // Version of the smithy-build.json file specification } ``` -------------------------------- ### Define Suppressions Metadata Type Source: https://github.com/smithy-lang/smithy/blob/main/designs/typed-metadata.md Example of defining the type for the 'suppressions' metadata key using the `@metadata` trait. This example defines a list of `MetadataSuppression` structures. ```smithy $version: "2.0" namespace smithy.api @metadata(key: "suppressions") list MetadataSuppressions { member: MetadataSuppression } structure MetadataSuppression { @required id: String @required @pattern("^(\*|[_a-zA-Z]\w*(\.[_a-zA-Z]\w*)*)$") namespace: String reason: String } ``` -------------------------------- ### Smithy Number Node Examples Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/spec/idl.rst Define numeric data using the NodeNumber production, similar to JSON numbers. Examples include integers, decimals, and scientific notation. ```smithy 0 ``` ```smithy 0.0 ``` ```smithy 1234 ``` ```smithy -1234.1234 ``` ```smithy 1e+2 ``` ```smithy 1.0e-10 ``` -------------------------------- ### Example Smithy Service Definition Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/index.rst Defines a Smithy service named Weather with associated resources and operations. This example showcases basic Smithy syntax for service, resource, and operation definitions. ```smithy $version: "2" namespace example.weather service Weather { version: "2006-03-01" resources: [City] operations: [GetCurrentTime] } resource City { identifiers: { cityId: CityId } read: GetCity list: ListCities resources: [Forecast] } ``` -------------------------------- ### Example Smithy model for :topdown selector Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/spec/selectors.rst This Smithy model demonstrates the usage of traits like aws.api#dataPlane and aws.api#controlPlane, which are used in :topdown selector examples to illustrate trait precedence and inheritance. ```smithy namespace smithy.example @aws.api#dataPlane service Example { version: "2020-09-08" resources: [Foo] operations: [OperationA] } operation OperationA {} @aws.api#controlPlane resource Foo { operations: [OperationB] } @aws.api#dataPlane operation OperationB {} ``` -------------------------------- ### Example of @default trait in an update operation Source: https://github.com/smithy-lang/smithy/blob/main/designs/defaults-and-model-evolution.md This example shows a Smithy operation with a top-level input member marked with the @default trait. Smithy will emit a warning for this pattern as it can lead to ambiguity in update operations. ```smithy $version: "2" namespace smithy.examnple operation UpdateUser { input: UpdateUserInput } structure UpdateUserInput { username: String = "" } ``` -------------------------------- ### Run Application and Server Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/tutorials/full-stack-tutorial.rst Command to build and run the web application alongside the server. This command simplifies the setup for testing the full-stack integration. ```sh make run ``` -------------------------------- ### Get Codegen Name for a Shape Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/guides/building-codegen/mapping-shapes-to-languages.rst Use `ShapeId#getName(ServiceShape)` to get the codegen-friendly name of a shape, considering potential renames within a service closure. Avoid using `ShapeId#getName()` directly. ```java String goodCodegenName = someShapeId.getName(someServiceShape); // Bad! String badCodegenName = someShapeId.getName(); ``` -------------------------------- ### Tree Rule Object Example Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/additional-specs/rules-engine/specification.rst An example of a tree rule object with conditions and subordinate rules. Tree rules are used to branch rule evaluation based on conditions and can contain other tree, endpoint, or error rules. ```json { "conditions": [ { "fn": "isValidHostLabel", "argv": [ { "ref": "linkId" } ] } ], "type": "tree", "rules": [ { "type": "tree", "conditions": [ // Abbreviated for clarity ], "rules": [ // Abbreviated for clarity ] }, { "type": "endpoint", ``` -------------------------------- ### Example Waiter Usage in Java Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/additional-specs/waiters.rst Demonstrates how to use a waiter to poll for an EC2 instance termination in Java. Requires an initialized client and instance IDs. ```java InstanceTerminatedWaiter waiter = InstanceTerminatedWaiter.builder() .client(myClient) .instanceIds(Collections.singletonList("i-foo")) .totalAllowedWaitTime(10, Duration.MINUTES) .wait(); ``` -------------------------------- ### Example Custom Codegen Context Record Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/guides/building-codegen/making-codegen-pluggable.rst An example of a Java record representing a custom codegen context for Python. This record would typically hold information accessible to the integration, such as the model, settings, symbol provider, and file manifest. ```java record PythonContext( ``` -------------------------------- ### Run Smithy Java Server Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/languages/java/quickstart.rst Start the coffee shop server using Gradle. The server will listen on port 8888. ```sh ./gradlew :server:run ``` -------------------------------- ### Example Python Codegen Settings Record Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/guides/building-codegen/making-codegen-pluggable.rst An example of a Java record used for codegen settings, capturing essential configuration like the service and protocol shape IDs. This pattern is suitable for basic configurations and can be extended with a builder pattern if needed. ```java record PythonSettings(ShapeId service, ShapeId protocol); ``` -------------------------------- ### Selector Compliance Test Example Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/spec/selectors.rst Demonstrates how to write selector compliance tests using the `selectorTests` metadata. This includes defining the selector, expected matches, and optional configurations like skipping prelude shapes. ```smithy $version: "2.0" metadata selectorTests = [ { selector: "[trait|length|min > 1]" matches: [ smithy.example#AtLeastTen ] } { selector: "[trait|length|min >= 1]" skipPreludeShapes: true matches: [ smithy.example#AtLeastOne smithy.example#AtLeastTen ] } { selector: "[trait|length|min < 2]" skipPreludeShapes: true matches: [ smithy.example#AtLeastOne ] } ] namespace smithy.example @length(min: 1) string AtLeastOne @length(max: 5) string AtMostFive @length(min: 10) string AtLeastTen ``` -------------------------------- ### :in Example Using Variables: Find Numbers in Operation Inputs Not Outputs Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/spec/selectors.rst Finds all numbers used in service operation inputs but not in service operation outputs, using variables and the :in function. Note: This example returns aggregate results across all services. ```none :caption: :in example using variables :name: in-variable-input-output-example service $outputs(~> operation -[output]-> ~> number) ~> operation -[input]-> ~> number :not(:in(${outputs})) ``` -------------------------------- ### Smithy Host Label Trait Example Source: https://github.com/smithy-lang/smithy/blob/main/docs/source-2.0/spec/endpoint-traits.rst This example demonstrates the usage of the hostLabel trait. It defines an operation 'GetStatus' with a hostPrefix that includes a label '{foo}'. The 'foo' member of the input structure 'GetStatusInput' is annotated with '@hostLabel', making its value dynamically inserted into the hostPrefix. ```smithy $version: "2" namespace smithy.example @readonly @endpoint(hostPrefix: "{foo}.data.") operation GetStatus { input: GetStatusInput output: GetStatusOutput } structure GetStatusInput { @required @hostLabel foo: String } ```