Compare commits
No commits in common. "9eaaada446b8fea4d49f1ddf33ab985126a4d89a" and "a4c6ec6dfe552c57bab601c7d99e8de02bbab1fe" have entirely different histories.
9eaaada446
...
a4c6ec6dfe
2 changed files with 5 additions and 45 deletions
8
.envrc
8
.envrc
|
@ -1,8 +0,0 @@
|
||||||
# vi: ft=sh
|
|
||||||
# shellcheck shell=bash
|
|
||||||
|
|
||||||
if ! has zvm_direnv_version || ! zvm_direnv_version 2.0.0; then
|
|
||||||
source_url "https://git.lerch.org/lobo/zvm-direnv/raw/tag/2.0.0/direnvrc" "sha256-8Umzxj32hFU6G0a7Wrq0KTNDQ8XEuje2A3s2ljh/hFY="
|
|
||||||
fi
|
|
||||||
|
|
||||||
use zig 0.14.0
|
|
|
@ -235,7 +235,7 @@ const Shape = union(ShapeType) {
|
||||||
traits: []Trait,
|
traits: []Trait,
|
||||||
},
|
},
|
||||||
service: struct {
|
service: struct {
|
||||||
version: ?[]const u8, // A version is optional in Smithy. https://smithy.io/2.0/spec/service-types.html
|
version: []const u8,
|
||||||
operations: [][]const u8,
|
operations: [][]const u8,
|
||||||
resources: [][]const u8,
|
resources: [][]const u8,
|
||||||
traits: []Trait,
|
traits: []Trait,
|
||||||
|
@ -482,7 +482,7 @@ fn getShape(allocator: std.mem.Allocator, shape: std.json.Value) SmithyParseErro
|
||||||
if (std.mem.eql(u8, shape_type, "service"))
|
if (std.mem.eql(u8, shape_type, "service"))
|
||||||
return Shape{
|
return Shape{
|
||||||
.service = .{
|
.service = .{
|
||||||
.version = if (shape.object.get("version")) |v| v.string else null,
|
.version = shape.object.get("version").?.string,
|
||||||
.operations = if (shape.object.get("operations")) |ops|
|
.operations = if (shape.object.get("operations")) |ops|
|
||||||
try parseTargetList(allocator, ops.array)
|
try parseTargetList(allocator, ops.array)
|
||||||
else
|
else
|
||||||
|
@ -812,7 +812,6 @@ fn getTrait(trait_type: []const u8, value: std.json.Value) SmithyParseError!?Tra
|
||||||
\\aws.cloudformation#cfnMutability
|
\\aws.cloudformation#cfnMutability
|
||||||
\\aws.cloudformation#cfnExcludeProperty
|
\\aws.cloudformation#cfnExcludeProperty
|
||||||
\\aws.cloudformation#cfnAdditionalIdentifier
|
\\aws.cloudformation#cfnAdditionalIdentifier
|
||||||
\\aws.endpoints#standardPartitionalEndpoints
|
|
||||||
\\aws.iam#actionPermissionDescription
|
\\aws.iam#actionPermissionDescription
|
||||||
\\aws.iam#requiredActions
|
\\aws.iam#requiredActions
|
||||||
\\aws.iam#conditionKeys
|
\\aws.iam#conditionKeys
|
||||||
|
@ -894,37 +893,6 @@ fn read_file_to_string(allocator: std.mem.Allocator, file_name: []const u8, max_
|
||||||
const test_data: []const u8 = @embedFile("test.json");
|
const test_data: []const u8 = @embedFile("test.json");
|
||||||
const intrinsic_type_count: usize = 15; // 15 intrinsic types are added to every model (see shapes() function)
|
const intrinsic_type_count: usize = 15; // 15 intrinsic types are added to every model (see shapes() function)
|
||||||
|
|
||||||
test "parse service without version" {
|
|
||||||
const test_string =
|
|
||||||
\\ {
|
|
||||||
\\ "smithy": "1.0",
|
|
||||||
\\ "shapes": {
|
|
||||||
\\ "com.amazonaws.sts#AWSSecurityTokenServiceV20110615": {
|
|
||||||
\\ "type": "service",
|
|
||||||
\\ "operations": [
|
|
||||||
\\ {
|
|
||||||
\\ "target": "op"
|
|
||||||
\\ }
|
|
||||||
\\ ]
|
|
||||||
\\ }
|
|
||||||
\\ }
|
|
||||||
\\ }
|
|
||||||
\\
|
|
||||||
\\
|
|
||||||
;
|
|
||||||
|
|
||||||
const allocator = std.testing.allocator;
|
|
||||||
const model = try parse(allocator, test_string);
|
|
||||||
defer model.deinit();
|
|
||||||
try expect(std.mem.eql(u8, model.version, "1.0"));
|
|
||||||
|
|
||||||
try std.testing.expectEqual(intrinsic_type_count + 1, model.shapes.len);
|
|
||||||
try std.testing.expectEqualStrings("com.amazonaws.sts#AWSSecurityTokenServiceV20110615", model.shapes[0].id);
|
|
||||||
try std.testing.expectEqualStrings("com.amazonaws.sts", model.shapes[0].namespace);
|
|
||||||
try std.testing.expectEqualStrings("AWSSecurityTokenServiceV20110615", model.shapes[0].name);
|
|
||||||
try std.testing.expect(model.shapes[0].member == null);
|
|
||||||
try std.testing.expect(model.shapes[0].shape.service.version == null);
|
|
||||||
}
|
|
||||||
test "parse string" {
|
test "parse string" {
|
||||||
const test_string =
|
const test_string =
|
||||||
\\ {
|
\\ {
|
||||||
|
@ -955,7 +923,7 @@ test "parse string" {
|
||||||
try std.testing.expectEqualStrings("com.amazonaws.sts", model.shapes[0].namespace);
|
try std.testing.expectEqualStrings("com.amazonaws.sts", model.shapes[0].namespace);
|
||||||
try std.testing.expectEqualStrings("AWSSecurityTokenServiceV20110615", model.shapes[0].name);
|
try std.testing.expectEqualStrings("AWSSecurityTokenServiceV20110615", model.shapes[0].name);
|
||||||
try std.testing.expect(model.shapes[0].member == null);
|
try std.testing.expect(model.shapes[0].member == null);
|
||||||
try std.testing.expectEqualStrings("2011-06-15", model.shapes[0].shape.service.version.?);
|
try std.testing.expectEqualStrings("2011-06-15", model.shapes[0].shape.service.version);
|
||||||
}
|
}
|
||||||
test "parse shape with member" {
|
test "parse shape with member" {
|
||||||
const test_string =
|
const test_string =
|
||||||
|
@ -985,7 +953,7 @@ test "parse shape with member" {
|
||||||
try std.testing.expectEqualStrings("com.amazonaws.sts#AWSSecurityTokenServiceV20110615$member", model.shapes[0].id);
|
try std.testing.expectEqualStrings("com.amazonaws.sts#AWSSecurityTokenServiceV20110615$member", model.shapes[0].id);
|
||||||
try std.testing.expectEqualStrings("com.amazonaws.sts", model.shapes[0].namespace);
|
try std.testing.expectEqualStrings("com.amazonaws.sts", model.shapes[0].namespace);
|
||||||
try std.testing.expectEqualStrings("AWSSecurityTokenServiceV20110615", model.shapes[0].name);
|
try std.testing.expectEqualStrings("AWSSecurityTokenServiceV20110615", model.shapes[0].name);
|
||||||
try std.testing.expectEqualStrings("2011-06-15", model.shapes[0].shape.service.version.?);
|
try std.testing.expectEqualStrings("2011-06-15", model.shapes[0].shape.service.version);
|
||||||
try std.testing.expectEqualStrings("member", model.shapes[0].member.?);
|
try std.testing.expectEqualStrings("member", model.shapes[0].member.?);
|
||||||
}
|
}
|
||||||
test "parse file" {
|
test "parse file" {
|
||||||
|
@ -1010,7 +978,7 @@ test "parse file" {
|
||||||
try std.testing.expectEqualStrings("com.amazonaws.sts#AWSSecurityTokenServiceV20110615", svc.id);
|
try std.testing.expectEqualStrings("com.amazonaws.sts#AWSSecurityTokenServiceV20110615", svc.id);
|
||||||
try std.testing.expectEqualStrings("com.amazonaws.sts", svc.namespace);
|
try std.testing.expectEqualStrings("com.amazonaws.sts", svc.namespace);
|
||||||
try std.testing.expectEqualStrings("AWSSecurityTokenServiceV20110615", svc.name);
|
try std.testing.expectEqualStrings("AWSSecurityTokenServiceV20110615", svc.name);
|
||||||
try std.testing.expectEqualStrings("2011-06-15", svc.shape.service.version.?);
|
try std.testing.expectEqualStrings("2011-06-15", svc.shape.service.version);
|
||||||
// Should be 6, but we don't handle title or xml namespace
|
// Should be 6, but we don't handle title or xml namespace
|
||||||
try std.testing.expectEqual(@as(usize, 4), svc.shape.service.traits.len);
|
try std.testing.expectEqual(@as(usize, 4), svc.shape.service.traits.len);
|
||||||
try std.testing.expectEqual(@as(usize, 8), svc.shape.service.operations.len);
|
try std.testing.expectEqual(@as(usize, 8), svc.shape.service.operations.len);
|
||||||
|
|
Loading…
Add table
Reference in a new issue