Skip to content

Commit

Permalink
Allow non-builtIn params to have default values
Browse files Browse the repository at this point in the history
  • Loading branch information
kstich committed Sep 19, 2023
1 parent 39bf43e commit 806b624
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ public final class Parameter extends SyntaxElement implements ToSmithyBuilder<Pa
private final String documentation;

private Parameter(Builder builder) {
if (builder.defaultValue != null && builder.builtIn == null) {
throw new RuntimeException("Cannot set a default value for non-builtin parameters");
}
if (builder.defaultValue != null && !builder.required) {
throw new RuntimeException("When a default value is set, the field must also be marked as required");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,20 @@ use smithy.rules#endpointTests

@clientContextParams(
bar: {type: "string", documentation: "a client string parameter"}
baz: {type: "string", documentation: "another client string parameter"}
)
@endpointRuleSet({
version: "1.0",
parameters: {
bar: {
type: "string",
documentation: "docs"
}
baz: {
type: "string",
documentation: "docs"
required: true
default: "baz"
},
endpoint: {
type: "string",
Expand All @@ -38,7 +45,7 @@ use smithy.rules#endpointTests
}
],
"endpoint": {
"url": "https://example.com"
"url": "https://example.com/{baz}"
},
"type": "endpoint"
},
Expand All @@ -65,7 +72,24 @@ use smithy.rules#endpointTests
}],
"expect": {
"endpoint": {
"url": "https://example.com"
"url": "https://example.com/baz"
}
}
},
{
"params": {
"bar": "a b",
"baz": "BIG"
}
"operationInputs": [{
"operationName": "GetThing",
"builtInParams": {
"SDK::Endpoint": "https://custom.example.com"
}
}],
"expect": {
"endpoint": {
"url": "https://example.com/BIG"
}
}
},
Expand Down

This file was deleted.

0 comments on commit 806b624

Please sign in to comment.