索托 Smithy

用于加载 AWS Smithy 文件及其 JSON AST 模型的库。Smithy 接口定义语言 (IDL) 为任何协议定义服务和文档。

Smithy IDL

Smithy 模型将服务定义为资源、操作和形状的集合。此库加载 Smithy IDL 和同构 JSON 抽象语法树 (AST) 表示。

例如,以下 Smithy IDL 示例表示一个 TimeService 服务,其中包含一个 GetServerTime 操作,该操作返回一个包含时间戳的 GetServerTimeOutput 结构。

namespace soto.example

service TimeService {
    version: "2020-10-01",
    operations: [GetServerTime],
}

operation GetServerTime {
    output: GetServerTimeOutput
}

structure GetServerTimeOutput {
    @required
    time: Timestamp
}

它可以表示为 Smithy JSON AST,如下所示

{
    "smithy": "1.0",
    "shapes": {
        "soto.example#TimeService": {
            "type": "service",
            "version": "2020-10-01"
            "operations": [
                {
                    "target": "soto.example#GetServerTime"
                }
            ]
        },
        "soto.example#GetServerTime": {
            "type": "operation",
            "output": {
                "target": "soto.example#GetServerTimeOutput"
            }
        },
        "soto.example#GetServerTimeOutput": {
            "type": "structure",
            "members": {
                "time": {
                    "target": "smithy.api#Timestamp",
                    "traits": {
                        "smithy.api#required": {}
                    }
                }
            }
        }
    }
}

支持

SotoSmithy 支持 Smithy 1.0 规范 中定义的所有标准形状和特征。它支持有限数量的选择器,包括形状和带特征的形状,例如

string [trait|sensitive]

SotoSmithyAWS

此库可用于读取任何 Smithy 文件,但专门用于解析 AWS 服务 Smithy 文件。还有一个额外的库 SotoSmithyAWS,其中包含加载 AWS 服务 Smithy 所需的特征。如果您想使用 AWS 特征库,您需要在加载任何文件之前通过调用以下内容向 SotoSmithy 注册这些特征。

Smithy.registerAWSTraits()