diff --git a/src/main/java/co/zeroae/gate/App.java b/src/main/java/co/zeroae/gate/App.java index 8144819..af74407 100644 --- a/src/main/java/co/zeroae/gate/App.java +++ b/src/main/java/co/zeroae/gate/App.java @@ -19,6 +19,7 @@ import java.io.IOException; import java.net.URL; import java.util.HashMap; +import java.util.HashSet; import java.util.Objects; /** @@ -71,9 +72,20 @@ public APIGatewayProxyResponseEvent handleRequest(APIGatewayProxyRequestEvent in * @param responseType One of the supported response types */ private String encode(Document doc, String responseType) throws IOException { + final FeatureMap exportOptions = Factory.newFeatureMap(); + + // Take *all* annotation types. + final AnnotationSet defaultAnnots = doc.getAnnotations(); + final HashSet annotationTypes = new HashSet<>(); + for (Annotation annotation: defaultAnnots.inDocumentOrder()) { + annotationTypes.add(annotation.getType()); + } + exportOptions.put("annotationTypes", annotationTypes); + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); if (responseType.equals("application/json")) { - gateJsonExporter.export(doc, baos); + gateJsonExporter.setAnnotationTypes(doc.getAnnotationSetNames()); + gateJsonExporter.export(doc, baos, exportOptions); return baos.toString(); } else { diff --git a/src/test/java/co/zeroae/gate/AppTest.java b/src/test/java/co/zeroae/gate/AppTest.java index 416f1d9..b39e41c 100644 --- a/src/test/java/co/zeroae/gate/AppTest.java +++ b/src/test/java/co/zeroae/gate/AppTest.java @@ -66,7 +66,7 @@ public void testApplicationJsonResponse() throws Exception { APIGatewayProxyRequestEvent input = new APIGatewayProxyRequestEvent() .withHttpMethod("POST") .withHeaders(Collections.unmodifiableMap(inputHeaders)) - .withBody("My name is Lambda Function and I approve this test."); + .withBody("Today is Monday."); final TestContext context = new TestContext(); final APIGatewayProxyResponseEvent result = app.handleRequest(input, context); assertEquals(result.getStatusCode().intValue(), 200);