Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Smithy 1.0 Rust JSON model - parse directly using json_serde, including model Traits
// Smithy 1.0 Rust JSON model - parse directly using json_serde, including model Traits
//
// Usage:
// mod smithy;
// let model: smithy::Model = serde_json::from_reader(reader).unwrap();
//
use std::{default::Default, collections::HashMap};
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[serde(untagged)]
pub enum Value {
Bool(bool),
Number(f64),
String(String),
Array(Vec<Option<Value>>),
Object(HashMap<String, Option<Value>>),
#[serde(skip)]
Default,
}
impl Default for Value {
fn default() -> Self { Value::Default }
}
#[derive(Serialize, Deserialize, Debug, Hash, Default, Clone, PartialEq, Eq)]
pub struct ShapeID(String);
#[allow(dead_code)]
impl ShapeID {
pub fn namespace(&self) -> &str {
self.0.split_once('#').map(|(start, _end)| start).unwrap_or(&self.0)
}
pub fn shape_name(&self) -> &str {
self.0.split_once('#').and_then(|(_start, end)| end.split_once('$').map(|(start, _end)| start).or_else(|| Some(end))).unwrap_or(&self.0)
}
pub fn member_name(&self) -> &str {
self.0.split_once('$').map(|(_start, end)| end).unwrap_or(&self.0)
}
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
pub struct Model {
pub smithy: String,
pub metadata: Option<HashMap<String, Option<Value>>>,
pub shapes: HashMap<ShapeID, Shape>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(untagged)]
pub enum Timestamp {
Integer(i32),
String(String),
#[serde(skip)]
Default,
}
impl Default for Timestamp {
fn default() -> Self { Timestamp::Default }
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[serde(tag = "type", rename_all = "camelCase")]
pub enum Shape {
Blob(SimpleShape),
Boolean(SimpleShape),
String(SimpleShape),
Byte(SimpleShape),
Short(SimpleShape),
Integer(SimpleShape),
Long(SimpleShape),
Float(SimpleShape),
Double(SimpleShape),
BigInteger(SimpleShape),
BigDecimal(SimpleShape),
Timestamp(SimpleShape),
Document(SimpleShape),
Member(Member),
List(List),
Set(Set),
Map(Map),
Structure(Structure),
Union(Structure),
Service(Service),
Operation(Operation),
Resource(Resource),
Apply(SimpleShape),
#[serde(skip)]
Default,
}
impl Default for Shape {
fn default() -> Self { Shape::Default }
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
pub struct SimpleShape {
pub traits: Option<Traits>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
pub struct Member {
pub target: ShapeID,
pub traits: Option<Traits>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
pub struct List {
pub member: Member,
pub traits: Option<Traits>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
pub struct Set {
pub member: Member,
pub traits: Option<Traits>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
pub struct Map {
pub key: Member,
pub value: Member,
pub traits: Option<Traits>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
pub struct Structure {
pub members: HashMap<String, Member>,
pub traits: Option<Traits>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
pub struct Service {
pub version: String,
pub operations: Option<Vec<Reference>>,
pub resources: Option<Vec<Reference>>,
pub errors: Option<Vec<Reference>>,
pub rename: Option<HashMap<ShapeID, String>>,
pub traits: Option<Traits>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
pub struct Reference {
pub target: ShapeID,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
pub struct Operation {
pub input: Option<Reference>,
pub output: Option<Reference>,
pub errors: Option<Vec<Reference>>,
pub traits: Option<Traits>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct Resource {
pub identifiers: Option<HashMap<String, ShapeID>>,
pub create: Option<ShapeID>,
pub put: Option<ShapeID>,
pub read: Option<ShapeID>,
pub update: Option<ShapeID>,
pub delete: Option<ShapeID>,
pub list: Option<ShapeID>,
pub operations: Option<Vec<ShapeID>>,
pub collection_operations: Option<Vec<ShapeID>>,
pub resources: Option<Vec<ShapeID>>,
pub traits: Option<Traits>,
}
// Traits
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub struct AnnotationTrait {}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub struct Traits {
#[serde(rename = "aws.api#arn")]
pub arn: Option<ArnTrait>,
#[serde(rename = "aws.api#arnReference")]
pub arn_reference: Option<ArnReferenceTrait>,
#[serde(rename = "aws.api#clientDiscoveredEndpoint")]
pub client_discovered_endpoint: Option<ClientDiscoveredEndpointTrait>,
#[serde(rename = "aws.api#clientEndpointDiscovery")]
pub client_endpoint_discovery: Option<ClientEndpointDiscoveryTrait>,
#[serde(rename = "aws.api#clientEndpointDiscoveryId")]
pub client_endpoint_discovery_id: Option<AnnotationTrait>,
#[serde(rename = "aws.api#controlPlane")]
pub control_plane: Option<AnnotationTrait>,
#[serde(rename = "aws.api#data")]
pub data: Option<String>,
#[serde(rename = "aws.api#dataPlane")]
pub data_plane: Option<AnnotationTrait>,
#[serde(rename = "aws.api#service")]
pub service: Option<ServiceTrait>,
#[serde(rename = "aws.apigateway#apiKeySource")]
pub api_key_source: Option<String>,
#[serde(rename = "aws.apigateway#authorizer")]
pub authorizer: Option<String>,
#[serde(rename = "aws.apigateway#authorizers")]
pub authorizers: Option<HashMap<String, AuthorizerTrait>>,
#[serde(rename = "aws.apigateway#integration")]
pub integration: Option<IntegrationTrait>,
#[serde(rename = "aws.apigateway#mockIntegration")]
pub mock_integration: Option<MockIntegrationTrait>,
#[serde(rename = "aws.apigateway#requestValidator")]
pub request_validator: Option<String>,
#[serde(rename = "aws.auth#cognitoUserPools")]
pub cognito_user_pools: Option<CognitoUserPoolsTrait>,
#[serde(rename = "aws.auth#sigv4")]
pub sig_v4: Option<SigV4Trait>,
#[serde(rename = "aws.auth#unsignedPayload")]
pub unsigned_payload: Option<AnnotationTrait>,
#[serde(rename = "aws.cloudformation#cfnAdditionalIdentifier")]
pub cfn_additional_identifier: Option<AnnotationTrait>,
#[serde(rename = "aws.cloudformation#cfnExcludeProperty")]
pub cfn_exclude_property: Option<AnnotationTrait>,
#[serde(rename = "aws.cloudformation#cfnMutability")]
pub cfn_mutability: Option<String>,
#[serde(rename = "aws.cloudformation#cfnResource")]
pub cfn_resource: Option<CfnResourceTrait>,
#[serde(rename = "aws.iam#actionPermissionDescription")]
pub action_permission_description: Option<String>,
#[serde(rename = "aws.iam#conditionKeys")]
pub condition_keys: Option<Vec<String>>,
#[serde(rename = "aws.iam#defineConditionKeys")]
pub define_condition_keys: Option<HashMap<String, DefineConditionKeysTrait>>,
#[serde(rename = "aws.iam#disableConditionKeyInference")]
pub disable_condition_key_inference: Option<AnnotationTrait>,
#[serde(rename = "aws.iam#iamResource")]
pub iam_resource: Option<IamResourceTrait>,
#[serde(rename = "aws.iam#requiredActions")]
pub required_actions: Option<Vec<String>>,
#[serde(rename = "aws.iam#supportedPrincipalTypes")]
pub supported_principal_types: Option<Vec<String>>,
#[serde(rename = "aws.protocols#awsJson1_0")]
pub aws_json1_0: Option<AnnotationTrait>,
#[serde(rename = "aws.protocols#awsJson1_1")]
pub aws_json1_1: Option<AnnotationTrait>,
#[serde(rename = "aws.protocols#awsQuery")]
pub aws_query: Option<AnnotationTrait>,
#[serde(rename = "aws.protocols#awsQueryError")]
pub aws_query_error: Option<AwsQueryErrorTrait>,
#[serde(rename = "aws.protocols#ec2Query")]
pub ec2_query: Option<AnnotationTrait>,
#[serde(rename = "aws.protocols#ec2QueryName")]
pub ec2_query_name: Option<String>,
#[serde(rename = "aws.protocols#httpChecksum")]
pub http_checksum: Option<HttpChecksumTrait>,
#[serde(rename = "aws.protocols#restJson1")]
pub rest_json1: Option<RestJson1Trait>,
#[serde(rename = "aws.protocols#restXml")]
pub rest_xml: Option<RestXmlTrait>,
#[serde(rename = "smithy.api#auth")]
pub auth: Option<Vec<String>>,
#[serde(rename = "smithy.api#authDefinition")]
pub auth_definition: Option<AuthDefinitionTrait>,
#[serde(rename = "smithy.api#box")]
pub r#box: Option<AnnotationTrait>,
#[serde(rename = "smithy.api#cors")]
pub cors: Option<CorsTrait>,
#[serde(rename = "smithy.api#deprecated")]
pub deprecated: Option<DeprecatedTrait>,
#[serde(rename = "smithy.api#documentation")]
pub documentation: Option<String>,
#[serde(rename = "smithy.api#endpoint")]
pub endpoint: Option<EndpointTrait>,
#[serde(rename = "smithy.api#enum")]
pub r#enum: Option<Vec<EnumTrait>>,
#[serde(rename = "smithy.api#error")]
pub error: Option<String>,
#[serde(rename = "smithy.api#eventHeader")]
pub event_header: Option<AnnotationTrait>,
#[serde(rename = "smithy.api#eventPayload")]
pub event_payload: Option<AnnotationTrait>,
#[serde(rename = "smithy.api#examples")]
pub examples: Option<Vec<ExamplesTrait>>,
#[serde(rename = "smithy.api#externalDocumentation")]
pub external_documentation: Option<HashMap<String, String>>,
#[serde(rename = "smithy.api#hostLabel")]
pub host_label: Option<AnnotationTrait>,
#[serde(rename = "smithy.api#http")]
pub http: Option<HttpTrait>,
#[serde(rename = "smithy.api#httpApiKeyAuth")]
pub http_api_key_auth: Option<HttpApiKeyAuthTrait>,
#[serde(rename = "smithy.api#httpBasicAuth")]
pub http_basic_auth: Option<AnnotationTrait>,
#[serde(rename = "smithy.api#httpBearerAuth")]
pub http_bearer_auth: Option<AnnotationTrait>,
#[serde(rename = "smithy.api#httpChecksumRequired")]
pub http_checksum_required: Option<AnnotationTrait>,
#[serde(rename = "smithy.api#httpDigestAuth")]
pub http_digest_auth: Option<AnnotationTrait>,
#[serde(rename = "smithy.api#httpError")]
pub http_error: Option<i32>,
#[serde(rename = "smithy.api#httpHeader")]
pub http_header: Option<String>,
#[serde(rename = "smithy.api#httpLabel")]
pub http_label: Option<AnnotationTrait>,
#[serde(rename = "smithy.api#httpPayload")]
pub http_payload: Option<AnnotationTrait>,
#[serde(rename = "smithy.api#httpPrefixHeaders")]
pub http_prefix_headers: Option<String>,
#[serde(rename = "smithy.api#httpQuery")]
pub http_query: Option<String>,
#[serde(rename = "smithy.api#httpQueryParams")]
pub http_query_params: Option<AnnotationTrait>,
#[serde(rename = "smithy.api#httpResponseCode")]
pub http_response_code: Option<AnnotationTrait>,
#[serde(rename = "smithy.api#idRef")]
pub id_ref: Option<IdRefTrait>,
#[serde(rename = "smithy.api#idempotencyToken")]
pub idempotency_token: Option<AnnotationTrait>,
#[serde(rename = "smithy.api#idempotent")]
pub idempotent: Option<AnnotationTrait>,
#[serde(rename = "smithy.api#internal")]
pub internal: Option<AnnotationTrait>,
#[serde(rename = "smithy.api#jsonName")]
pub json_name: Option<String>,
#[serde(rename = "smithy.api#mediaType")]
pub media_type: Option<String>,
#[serde(rename = "smithy.api#noReplace")]
pub no_replace: Option<AnnotationTrait>,
#[serde(rename = "smithy.api#optionalAuth")]
pub optional_auth: Option<AnnotationTrait>,
#[serde(rename = "smithy.api#paginated")]
pub paginated: Option<PaginatedTrait>,
#[serde(rename = "smithy.api#pattern")]
pub pattern: Option<String>,
#[serde(rename = "smithy.api#private")]
pub private: Option<AnnotationTrait>,
#[serde(rename = "smithy.api#protocolDefinition")]
pub protocol_definition: Option<ProtocolDefinitionTrait>,
#[serde(rename = "smithy.api#range")]
pub range: Option<RangeTrait>,
#[serde(rename = "smithy.api#readonly")]
pub readonly: Option<AnnotationTrait>,
#[serde(rename = "smithy.api#recommended")]
pub recommended: Option<RecommendedTrait>,
#[serde(rename = "smithy.api#references")]
pub references: Option<Vec<ReferencesTrait>>,
#[serde(rename = "smithy.api#required")]
pub required: Option<AnnotationTrait>,
#[serde(rename = "smithy.api#requiresLength")]
pub requires_length: Option<AnnotationTrait>,
#[serde(rename = "smithy.api#resourceIdentifier")]
pub resource_identifier: Option<String>,
#[serde(rename = "smithy.api#retryable")]
pub retryable: Option<RetryableTrait>,
#[serde(rename = "smithy.api#sensitive")]
pub sensitive: Option<AnnotationTrait>,
#[serde(rename = "smithy.api#since")]
pub since: Option<String>,
#[serde(rename = "smithy.api#sparse")]
pub sparse: Option<String>,
#[serde(rename = "smithy.api#streaming")]
pub streaming: Option<AnnotationTrait>,
#[serde(rename = "smithy.api#tags")]
pub tags: Option<Vec<String>>,
#[serde(rename = "smithy.api#timestampFormat")]
pub timestamp_format: Option<String>,
#[serde(rename = "smithy.api#title")]
pub title: Option<String>,
#[serde(rename = "smithy.api#uniqueItems")]
pub unique_items: Option<AnnotationTrait>,
#[serde(rename = "smithy.api#unstable")]
pub unstable: Option<AnnotationTrait>,
#[serde(rename = "smithy.api#xmlAttribute")]
pub xml_attribute: Option<AnnotationTrait>,
#[serde(rename = "smithy.api#xmlFlattened")]
pub xml_flattened: Option<AnnotationTrait>,
#[serde(rename = "smithy.api#xmlName")]
pub xml_name: Option<String>,
#[serde(rename = "smithy.api#xmlNamespace")]
pub xml_namespace: Option<XmlNamespaceTrait>,
#[serde(rename = "smithy.mqtt#publish")]
pub publish: Option<String>,
#[serde(rename = "smithy.mqtt#subscribe")]
pub subscribe: Option<String>,
#[serde(rename = "smithy.mqtt#topicLabel")]
pub topic_label: Option<AnnotationTrait>,
#[serde(rename = "smithy.test#httpMalformedRequestTests")]
pub http_malformed_request_tests: Option<Vec<HttpMalformedRequestTestsTrait>>,
#[serde(rename = "smithy.test#httpRequestTests")]
pub http_request_tests: Option<Vec<HttpRequestTestsTrait>>,
#[serde(rename = "smithy.test#httpResponseTests")]
pub http_response_tests: Option<Vec<HttpResponseTestsTrait>>,
#[serde(rename = "smithy.waiters#waitable")]
pub waitable: Option<HashMap<String, WaitableTrait>>,
#[serde(flatten)]
pub other: Option<HashMap<String, Value>>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct ArnTrait {
pub template: String,
pub no_region: Option<bool>,
pub no_account: Option<bool>,
pub absolute: Option<bool>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
pub struct ArnReferenceTrait {
pub r#type: Option<String>,
pub service: Option<String>,
pub resource: Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
pub struct ClientDiscoveredEndpointTrait {
pub required: Option<bool>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
pub struct ClientEndpointDiscoveryTrait {
pub operation: ShapeID,
pub error: Option<ShapeID>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct ServiceTrait {
pub sdk_id: String,
pub cloud_formation_name: Option<String>,
pub arn_namespace: Option<String>,
pub cloud_trail_event_source: Option<String>,
pub endpoint_prefix: Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct AuthorizerTrait {
pub scheme: String,
pub r#type: Option<String>,
pub custom_auth_type: Option<String>,
pub uri: Option<String>,
pub credentials: Option<String>,
pub identity_source: Option<String>,
pub idntity_validation_expression: Option<String>,
pub result_ttl_in_seconds: Option<i32>
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct IntegrationTrait {
pub r#type: String,
pub uri: String,
pub http_method: String,
pub credentials: Option<String>,
pub pass_through_behavior: Option<String>,
pub content_handling: Option<String>,
pub timeout_in_millis: Option<i32>,
pub connection_id: Option<String>,
pub connection_type: Option<String>,
pub cache_namespace: Option<String>,
pub payload_format_version: Option<String>,
pub cache_key_parameters: Option<Vec<String>>,
pub request_parameters: Option<HashMap<String, String>>,
pub request_templates: Option<HashMap<String, String>>,
pub responses: Option<HashMap<String, ApiGatewayResponse>>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct ApiGatewayResponse {
pub status_code: Option<String>,
pub response_templates: Option<HashMap<String, String>>,
pub response_parameters: Option<HashMap<String, String>>,
pub content_handling: Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct MockIntegrationTrait {
pub pass_through_behavior: Option<String>,
pub request_parameters: Option<HashMap<String, String>>,
pub request_templates: Option<HashMap<String, String>>,
pub responses: Option<HashMap<String, ApiGatewayResponse>>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct CognitoUserPoolsTrait {
pub provider_arns: Vec<String>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
pub struct SigV4Trait {
pub name: String,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct CfnResourceTrait {
pub name: Option<String>,
pub additional_schemas: Option<Vec<ShapeID>>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct DefineConditionKeysTrait {
pub r#type: String,
pub documentation: Option<String>,
pub external_documentation: Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
pub struct IamResourceTrait {
pub name: Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct AwsQueryErrorTrait {
pub code: String,
pub http_response_code: i32,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct HttpChecksumTrait {
pub request_algorithm_member: Option<String>,
pub request_checksum_required: Option<bool>,
pub request_validation_mode_member: Option<String>,
pub response_algorithms: Option<Vec<String>>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct RestJson1Trait {
pub http: Option<Vec<String>>,
pub event_stream_http: Option<Vec<String>>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct RestXmlTrait {
pub http: Option<Vec<String>>,
pub event_stream_http: Option<Vec<String>>,
pub no_error_wrapping: Option<bool>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
pub struct AuthDefinitionTrait {
pub traits: Vec<ShapeID>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct CorsTrait {
pub origin: Option<String>,
pub max_age: Option<i32>,
pub additional_allowed_headers: Option<Vec<String>>,
pub additional_exposed_headers: Option<Vec<String>>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct DeprecatedTrait {
pub message: Option<String>,
pub since: Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct EndpointTrait {
pub host_prefix: String
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct EnumTrait {
pub value: String,
pub name: Option<String>,
pub documentation: Option<String>,
pub tags: Option<Vec<String>>,
pub deprecated: Option<bool>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct ExamplesTrait {
pub title: String,
pub documentation: Option<String>,
pub input: Option<Value>,
pub output: Option<Value>,
pub error: Option<ErrorExample>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct ErrorExample {
pub shape_id: Option<ShapeID>,
pub content: Option<Value>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
pub struct HttpTrait {
pub method: String,
pub uri: String,
pub code: Option<i32>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
pub struct HttpApiKeyAuthTrait {
pub name: String,
pub r#in: String,
pub scheme: Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct IdRefTrait {
pub fail_when_missing: Option<bool>,
pub selector: Option<String>,
pub error_message: Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct PaginatedTrait {
pub input_token: Option<String>,
pub output_token: Option<String>,
pub items: Option<String>,
pub page_size: Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct ProtocolDefinitionTrait {
pub traits: Option<Vec<ShapeID>>,
pub no_inline_document_support: Option<bool>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
pub struct RangeTrait {
pub min: Option<f64>,
pub max: Option<f64>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
pub struct RecommendedTrait {
pub reason: Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
pub struct ReferencesTrait {
pub service: Option<ShapeID>,
pub resource: ShapeID,
pub ids: Option<HashMap<String, String>>,
pub rel: Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
pub struct RetryableTrait {
pub throttling: Option<bool>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
pub struct XmlNamespaceTrait {
pub uri: String,
pub prefix: Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct HttpMalformedRequestTestsTrait {
pub id: String,
pub protocol: ShapeID,
pub request: HttpMalformedRequest,
pub response: HttpMalformedResponse,
pub documentation: Option<String>,
pub tags: Option<Vec<String>>,
pub test_parameters: Option<HashMap<String, Vec<String>>>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct HttpMalformedRequest {
pub method: String,
pub uri: String,
pub host: Option<String>,
pub query_params: Option<Vec<String>>,
pub headers: Option<HashMap<String, String>>,
pub body: String,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
pub struct HttpMalformedResponse {
pub headers: Option<HashMap<String, String>>,
pub code: i32,
pub body: Option<HttpMalformedResponseBody>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct HttpMalformedResponseBody {
pub assertion: HttpMalformedResponseBodyAssertion,
pub media_type: String,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct HttpMalformedResponseBodyAssertion {
pub contents: Option<String>,
pub message_regex: Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct HttpRequestTestsTrait {
pub id: String,
pub protocol: ShapeID,
pub method: String,
pub uri: String,
pub host: Option<String>,
pub resolved_host: Option<String>,
pub auth_scheme: Option<ShapeID>,
pub query_params: Option<Vec<String>>,
pub forbid_query_params: Option<Vec<String>>,
pub require_query_params: Option<Vec<String>>,
pub headers: Option<HashMap<String, String>>,
pub forbid_headers: Option<Vec<String>>,
pub require_headers: Option<Vec<String>>,
pub body: Option<String>,
pub body_media_type: Option<String>,
pub params: Option<Value>,
pub vendor_params: Option<Value>,
pub vendor_params_shape: Option<ShapeID>,
pub documentation: Option<String>,
pub tags: Option<Vec<String>>,
pub applies_to: Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct HttpResponseTestsTrait {
pub id: String,
pub protocol: String,
pub code: i32,
pub auth_scheme: Option<ShapeID>,
pub headers: Option<HashMap<String, String>>,
pub forbid_headers: Option<Vec<String>>,
pub require_headers: Option<Vec<String>>,
pub body: Option<String>,
pub body_media_type: Option<String>,
pub params: Option<Value>,
pub vendor_params: Option<Value>,
pub vendor_params_shape: Option<ShapeID>,
pub documentation: Option<String>,
pub tags: Option<Vec<String>>,
pub applies_to: Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct WaitableTrait {
pub documentation: Option<String>,
pub acceptors: Vec<Acceptor>,
pub min_delay: Option<i32>,
pub max_delay: Option<i32>,
pub deprecated: Option<bool>,
pub tags: Option<Vec<String>>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
pub struct Acceptor {
pub state: AcceptorState,
pub matcher: Matcher,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub enum AcceptorState {
Success,
Failure,
Retry,
#[serde(skip)]
Default,
}
impl Default for AcceptorState {
fn default() -> Self { AcceptorState::Default }
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct Matcher {
pub output: Option<PathMatcher>,
pub input_output: Option<PathMatcher>,
pub success: Option<bool>,
pub error_type: Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
pub struct PathMatcher {
pub path: String,
pub expected: String,
pub comparator: PathComparator,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub enum PathComparator {
StringEquals,
BooleanEquals,
AllStringEquals,
AnyStringEquals,
#[serde(skip)]
Default,
}
impl Default for PathComparator {
fn default() -> Self { PathComparator::Default }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment