fix(apigateway): support _custom_id_ tag on create-rest-api (#644)

When create-rest-api includes tags: {"_custom_id_": "ALIAS"}, use the
tag value as the API ID instead of the random 10-char shortId. This
matches LocalStack behavior and allows callers to invoke the API at
/execute-api/ALIAS/{stage}/{path} without knowing the auto-generated ID.

Also include tags in the create/get REST API response.

Fixes #636
This commit is contained in:
Hector Ventura authored and GitHub committed 2026-04-29 00:27:52 -05:00
1 parent 160a0a35d6
commit cb0a82b749
3 files changed
+49 -1

No files matched your search

@@ -336,4 +336,39 @@ class ApiGatewayIntegrationTest {
.then()
.statusCode(404);
}
// ──────────────────────────── _custom_id_ tag ────────────────────────────
@Test @Order(50)
void createRestApi_customIdTag_usesTagValueAsApiId() {
String body = """
{"name":"custom-id-api","tags":{"_custom_id_":"MYCUSTOMNAME"}}
""";
given()
.contentType(ContentType.JSON)
.body(body)
.when().post("/restapis")
.then()
.statusCode(201)
.body("id", equalTo("MYCUSTOMNAME"))
.body("tags._custom_id_", equalTo("MYCUSTOMNAME"));
}
@Test @Order(51)
void getRestApi_customId_resolvesById() {
given()
.when().get("/restapis/MYCUSTOMNAME")
.then()
.statusCode(200)
.body("id", equalTo("MYCUSTOMNAME"))
.body("name", equalTo("custom-id-api"));
}
@Test @Order(52)
void deleteRestApi_customId() {
given()
.when().delete("/restapis/MYCUSTOMNAME")
.then()
.statusCode(202);
}
}