mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(apigateway): accept any Content-Type on Put/ImportRestApi (#925)
* fix(apigateway): accept any Content-Type on PutRestApi and ImportRestApi The class-level @Consumes restricted these endpoints to application/json and application/json-patch+json, so JAX-RS returned 415 for any other Content-Type. The Terraform AWS provider sends the OpenAPI body as application/octet-stream, which broke aws_api_gateway_rest_api with an inline body. Use @Consumes(WILDCARD) on createRestApi and putRestApi, matching the pattern already used for opaque-body endpoints in BedrockRuntime, S3Control, and AppConfig. The underlying Swagger parser content-sniffs the body, so JSON and YAML payloads keep working regardless of the declared Content-Type. Closes #855 * ci: re-trigger sdk-test-node after transient npm registry 404
This commit is contained in:
1 parent
d89270c538
commit
b8d1b817c9
2 files changed
+76
No files matched your search
+74
@@ -1288,6 +1288,80 @@ class ApiGatewayOpenApiImportTest {
|
||||
given().delete("/restapis/" + apiId);
|
||||
}
|
||||
|
||||
// ──────────────────────────── Content-Type Tolerance ────────────────────────────
|
||||
|
||||
@Test
|
||||
@Order(70)
|
||||
void importRestApi_octetStreamContentType() throws Exception {
|
||||
String spec = """
|
||||
{"openapi": "3.0.1", "info": {"title": "OctetImport", "version": "1.0"}, "paths": {}}
|
||||
""";
|
||||
String body = given()
|
||||
.contentType("application/octet-stream")
|
||||
.queryParam("mode", "import")
|
||||
.body(spec.getBytes())
|
||||
.when()
|
||||
.post("/restapis")
|
||||
.then()
|
||||
.statusCode(201)
|
||||
.body("name", equalTo("OctetImport"))
|
||||
.extract().body().asString();
|
||||
|
||||
String apiId = mapper.readTree(body).get("id").asText();
|
||||
given().delete("/restapis/" + apiId);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(71)
|
||||
void putRestApi_noContentType() throws Exception {
|
||||
String createBody = given()
|
||||
.contentType(ContentType.JSON)
|
||||
.body("{\"name\": \"NoCtype\"}")
|
||||
.post("/restapis")
|
||||
.then().statusCode(201).extract().body().asString();
|
||||
String apiId = mapper.readTree(createBody).get("id").asText();
|
||||
|
||||
String spec = """
|
||||
{"openapi": "3.0.1", "info": {"title": "NoCtypeOverwritten", "version": "1.0"}, "paths": {}}
|
||||
""";
|
||||
given()
|
||||
.queryParam("mode", "overwrite")
|
||||
.body(spec.getBytes())
|
||||
.when()
|
||||
.put("/restapis/" + apiId)
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("name", equalTo("NoCtypeOverwritten"));
|
||||
|
||||
given().delete("/restapis/" + apiId);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(72)
|
||||
void putRestApi_octetStreamContentType() throws Exception {
|
||||
String createBody = given()
|
||||
.contentType(ContentType.JSON)
|
||||
.body("{\"name\": \"OctetOverwrite\"}")
|
||||
.post("/restapis")
|
||||
.then().statusCode(201).extract().body().asString();
|
||||
String apiId = mapper.readTree(createBody).get("id").asText();
|
||||
|
||||
String spec = """
|
||||
{"openapi": "3.0.1", "info": {"title": "OctetOverwritten", "version": "1.0"}, "paths": {}}
|
||||
""";
|
||||
given()
|
||||
.contentType("application/octet-stream")
|
||||
.queryParam("mode", "overwrite")
|
||||
.body(spec.getBytes())
|
||||
.when()
|
||||
.put("/restapis/" + apiId)
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("name", equalTo("OctetOverwritten"));
|
||||
|
||||
given().delete("/restapis/" + apiId);
|
||||
}
|
||||
|
||||
// ──────────────────────────── Cleanup ────────────────────────────
|
||||
|
||||
@Test
|
||||
|
||||
Reference in new issue
Block a user