Skip to content

Commit 04c26d6

Browse files
committed
Add a protocol test for endpoints that contain path prefixes
Sometimes, a service will have a path prefix that is not modeled. This adds a test that ensures REST-JSON clients will properly take that path into account.
1 parent c125366 commit 04c26d6

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

docs/source/1.0/spec/http-protocol-compliance-tests.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,12 @@ that support the following members:
105105
the query string (for example, "/foo/bar").
106106
* - host
107107
- ``string``
108-
- The host / endpoint provided to the client, not including the path or
109-
scheme (for example, "example.com").
108+
- The host / endpoint provided to the client (for example, "example.com").
109+
``host`` MAY contain a path to indicate a base path from which each
110+
operation in the service is appended to. For example, given a ``host``
111+
of ``example.com/foo/bar`` and an operation path of ``/MyOperation``,
112+
the resolved host of the operation is ``example.com`` and the resolved
113+
path is ``/foo/bar/MyOperation``.
110114
* - resolvedHost
111115
- ``string``
112116
- The host / endpoint that the client should send to, not including the
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// This file defines tests to ensure that implementations support endpoints with paths
2+
3+
$version: "1.0"
4+
5+
namespace aws.protocoltests.restjson
6+
7+
use aws.protocols#restJson1
8+
use smithy.test#httpRequestTests
9+
10+
@httpRequestTests([
11+
{
12+
id: "RestJsonHostWithPath",
13+
documentation: """
14+
Custom endpoints supplied by users can have paths""",
15+
protocol: restJson1,
16+
method: "GET",
17+
uri: "/custom/HostWithPathOperation",
18+
body: "",
19+
host: "example.com/custom",
20+
appliesTo: "client"
21+
}
22+
])
23+
@http(uri: "/HostWithPathOperation", method: "GET")
24+
operation HostWithPathOperation {}

smithy-aws-protocol-tests/model/restJson1/main.smithy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,8 @@ service RestJson {
8686
// @endpoint and @hostLabel trait tests
8787
EndpointOperation,
8888
EndpointWithHostLabelOperation,
89+
90+
// custom endpoints with paths
91+
HostWithPathOperation,
8992
]
9093
}

0 commit comments

Comments
 (0)