Skip to content

Commit

Permalink
V1.10 (#15)
Browse files Browse the repository at this point in the history
* update to latest spec

* fix property types that appears in a not compatible format and looks more like a type aliases
  • Loading branch information
stanb authored Mar 30, 2019
1 parent f976944 commit 11ed991
Show file tree
Hide file tree
Showing 301 changed files with 9,273 additions and 457 deletions.
2 changes: 1 addition & 1 deletion src/Comformation.CodeBuilder/Schema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class ResourceSpec
public IDictionary<string, Property> Properties { get; set; }
}

public class PropertySpec
public class PropertySpec : Property
{
public string Documentation { get; set; }
public IDictionary<string, Property> Properties { get; set; }
Expand Down
19 changes: 18 additions & 1 deletion src/Comformation.CodeBuilder/SchemaParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ public class SchemaParser

private IEnumerable<PropertyTypeClass> Parse(IDictionary<string, PropertySpec> propertySpecs)
{
var propertyClasses = propertySpecs.Select(x =>
var aliases = propertySpecs
.Where(x => x.Value.Properties == null)
.ToDictionary(x => x.Key, x => x.Value as Property);

var propertyClasses = propertySpecs.Where(x => x.Value.Properties != null).Select(x =>
{
var keyParts = x.Key.Split('.').Reverse().ToArray();
var className = keyParts[0];
Expand All @@ -41,6 +45,19 @@ private IEnumerable<PropertyTypeClass> Parse(IDictionary<string, PropertySpec> p
}
path = Path.ChangeExtension(path, ".cs");

// Fix aliases
foreach (var prop in x.Value.Properties)
{
var aliasName = $"{x.Key.Split(".")[0]}.{prop.Value.ItemType ?? prop.Value.Type}";
if (aliases.TryGetValue(aliasName, out var aliasType))
{
prop.Value.Type = aliasType.Type;
prop.Value.ItemType = aliasType.ItemType;
prop.Value.PrimitiveType = aliasType.PrimitiveType;
prop.Value.PrimitiveItemType = aliasType.PrimitiveItemType;
}
}

var propertyClass = new PropertyTypeClass
{
Name = className,
Expand Down
2 changes: 1 addition & 1 deletion src/Comformation/Comformation.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageId>Comformation</PackageId>
<Product>Comformation.NET</Product>
<PackageTags>cloudformation,aws-cloudformation,cloudformation-template,aws</PackageTags>
<Version>1.9.0</Version>
<Version>1.10.0</Version>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>bin\Debug\netstandard2.0\Comformation.xml</DocumentationFile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ public class ApiKeyProperties

/// <summary>
/// Value
/// The value of the API key.
/// Required: No
/// Type: String
/// Update requires: Replacement
/// </summary>
public Union<string, IntrinsicFunction> Value { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class EndpointConfiguration
/// Types
/// A list of endpoint types of an API or its custom domain name. Valid values include:
/// EDGE: For an edge-optimized API and its custom domain name. REGIONAL: For a regional API and its
/// custom domain name. PRIVATE : For a private API and its custom domain name.
/// custom domain name. PRIVATE : For a private API.
/// Required: No
/// Type: List of String values
/// Update requires: No interruption
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class ApiStage
/// Map containing method-level throttling information for API stage in a usage plan.
/// Duplicates are not allowed.
/// Required: No
/// Type: Map of string-to-Amazon API Gateway UsagePlan ThrottleSettings
/// Type: Map of string-to-ThrottleSettings
/// Update requires: No interruption
/// </summary>
[JsonProperty("Throttle")]
Expand Down
87 changes: 87 additions & 0 deletions src/Comformation/Generated/ApiGatewayV2/Api/ApiResource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
using System;
using System.Collections.Generic;
using Comformation.IntrinsicFunctions;

namespace Comformation.ApiGatewayV2.Api
{
/// <summary>
/// AWS::ApiGatewayV2::Api
/// The AWS::ApiGatewayV2::Api resource contains an Amazon API Gateway API. For more information, see CreateApi in
/// the Amazon API Gateway V2 API Reference.
/// https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html
/// </summary>
public class ApiResource : ResourceBase
{
public class ApiProperties
{
/// <summary>
/// RouteSelectionExpression
/// The route selection expression for the API.
/// Required: Yes
/// Type: String
/// Update requires: No interruption
/// </summary>
public Union<string, IntrinsicFunction> RouteSelectionExpression { get; set; }

/// <summary>
/// Description
/// The description of the API.
/// Required: No
/// Type: String
/// Update requires: No interruption
/// </summary>
public Union<string, IntrinsicFunction> Description { get; set; }

/// <summary>
/// Version
/// A version identifier for the API.
/// Required: No
/// Type: String
/// Update requires: No interruption
/// </summary>
public Union<string, IntrinsicFunction> Version { get; set; }

/// <summary>
/// ProtocolType
/// The API protocol.
/// Required: Yes
/// Type: String
/// Update requires: Replacement
/// </summary>
public Union<string, IntrinsicFunction> ProtocolType { get; set; }

/// <summary>
/// DisableSchemaValidation
/// Avoid validating models when creating a deployment.
/// Required: No
/// Type: Boolean
/// Update requires: No interruption
/// </summary>
public Union<bool, IntrinsicFunction> DisableSchemaValidation { get; set; }

/// <summary>
/// Name
/// The name of the API.
/// Required: Yes
/// Type: String
/// Update requires: No interruption
/// </summary>
public Union<string, IntrinsicFunction> Name { get; set; }

/// <summary>
/// ApiKeySelectionExpression
/// An API key selection expression.
/// Required: No
/// Type: String
/// Update requires: No interruption
/// </summary>
public Union<string, IntrinsicFunction> ApiKeySelectionExpression { get; set; }

}

public string Type { get; } = "AWS::ApiGatewayV2::Api";

public ApiProperties Properties { get; } = new ApiProperties();

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
using System;
using System.Collections.Generic;
using Comformation.IntrinsicFunctions;

namespace Comformation.ApiGatewayV2.Authorizer
{
/// <summary>
/// AWS::ApiGatewayV2::Authorizer
/// The AWS::ApiGatewayV2::Authorizer resource creates an authorization layer for an Amazon API Gateway (API
/// Gateway) API.
/// https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-authorizer.html
/// </summary>
public class AuthorizerResource : ResourceBase
{
public class AuthorizerProperties
{
/// <summary>
/// IdentityValidationExpression
/// A validation expression for the incoming identity. If you specify TOKEN for the authorizer&#39;s Type
/// property, specify a regular expression. API Gateway uses the expression to attempt to match the
/// incoming client token, and proceeds if the token matches. If the token doesn&#39;t match, API Gateway
/// responds with a 401 (unauthorized request) error code.
/// Required: No
/// Type: String
/// Update requires: No interruption
/// </summary>
public Union<string, IntrinsicFunction> IdentityValidationExpression { get; set; }

/// <summary>
/// AuthorizerUri
/// The authorizer&#39;s Uniform Resource Identifier (URI). If you specify TOKEN for the authorizer&#39;s Type
/// property, specify a Lambda function URI that has the form
/// arn:aws:apigateway:region:lambda:path/path. The path usually has the form
/// /2015-03-31/functions/LambdaFunctionARN/invocations.
/// Required: Yes
/// Specify this property for Lambda functions only.
/// Type: String
/// Update requires: No interruption
/// </summary>
public Union<string, IntrinsicFunction> AuthorizerUri { get; set; }

/// <summary>
/// AuthorizerCredentialsArn
/// The credentials that are required for the authorizer. To specify an AWS Identity and Access
/// Management (IAM) role that API Gateway assumes, specify the role&#39;s Amazon Resource Name (ARN). To
/// use resource-based permissions on the AWS Lambda (Lambda) function, specify null.
/// Required: No
/// Type: String
/// Update requires: No interruption
/// </summary>
public Union<string, IntrinsicFunction> AuthorizerCredentialsArn { get; set; }

/// <summary>
/// AuthorizerType
/// The authorizer type. Currently the only valid value is REQUEST, for a Lambda function using incoming
/// request parameters.
/// Required: Yes
/// Type: String
/// Update requires: No interruption
/// </summary>
public Union<string, IntrinsicFunction> AuthorizerType { get; set; }

/// <summary>
/// AuthorizerResultTtlInSeconds
/// The time-to-live (TTL) period, in seconds, that specifies how long API Gateway caches authorizer
/// results. If you specify a value greater than 0, API Gateway caches the authorizer responses. By
/// default, API Gateway sets this property to 300. The maximum value is 3600, or 1 hour.
/// Required: No
/// Type: Integer
/// Update requires: No interruption
/// </summary>
public Union<int, IntrinsicFunction> AuthorizerResultTtlInSeconds { get; set; }

/// <summary>
/// IdentitySource
/// The source of the identity in an incoming request.
/// If you specify REQUEST for the Type property, specify a comma-separated string of one or more
/// mapping expressions of the specified request parameter using the form method. request. parameter.
/// name.
/// Required: Yes
/// Type: List of String values
/// Update requires: No interruption
/// </summary>
public List<Union<string, IntrinsicFunction>> IdentitySource { get; set; }

/// <summary>
/// ApiId
/// The ID of the Api resource that API Gateway creates the authorizer in.
/// Required: Yes
/// Type: String
/// Update requires: Replacement
/// </summary>
public Union<string, IntrinsicFunction> ApiId { get; set; }

/// <summary>
/// Name
/// The name of the authorizer.
/// Required: Yes
/// Type: String
/// Update requires: No interruption
/// </summary>
public Union<string, IntrinsicFunction> Name { get; set; }

}

public string Type { get; } = "AWS::ApiGatewayV2::Authorizer";

public AuthorizerProperties Properties { get; } = new AuthorizerProperties();

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using Comformation.IntrinsicFunctions;

namespace Comformation.ApiGatewayV2.Deployment
{
/// <summary>
/// AWS::ApiGatewayV2::Deployment
/// The AWS::ApiGatewayV2::Deployment resource represents a deployment for an API. For more information, see
/// CreateDeployment in the Amazon API Gateway V2 API Reference.
/// https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-deployment.html
/// </summary>
public class DeploymentResource : ResourceBase
{
public class DeploymentProperties
{
/// <summary>
/// Description
/// Describes the stage that API Gateway creates with this deployment.
/// Required: No
/// Type: String
/// Update requires: No interruption
/// </summary>
public Union<string, IntrinsicFunction> Description { get; set; }

/// <summary>
/// StageName
/// A name for the stage that API Gateway creates with this deployment. Use only alphanumeric
/// characters.
/// Required: No
/// Type: String
/// Update requires: No interruption
/// </summary>
public Union<string, IntrinsicFunction> StageName { get; set; }

/// <summary>
/// ApiId
/// The ID of the Api resource to deploy.
/// Required: Yes
/// Type: String
/// Update requires: Replacement
/// </summary>
public Union<string, IntrinsicFunction> ApiId { get; set; }

}

public string Type { get; } = "AWS::ApiGatewayV2::Deployment";

public DeploymentProperties Properties { get; } = new DeploymentProperties();

}
}
Loading

0 comments on commit 11ed991

Please sign in to comment.