diff --git a/core/src/main/resources/reference.conf b/core/src/main/resources/reference.conf
index 796bf00..a11b71a 100644
--- a/core/src/main/resources/reference.conf
+++ b/core/src/main/resources/reference.conf
@@ -63,7 +63,6 @@ assets {
openapi {
-
basePath= ${application.path}"/openapi"
redocPath= "redoc"
@@ -95,6 +94,10 @@ openapi {
description="Default Server"
}
]
+
+ converters = [
+ "io.sinistral.proteus.openapi.jaxrs2.ServerModelResolver"
+ ]
}
diff --git a/core/src/test/resources/logback-test.xml b/core/src/test/resources/logback-test.xml
index 8763c33..44a9e83 100644
--- a/core/src/test/resources/logback-test.xml
+++ b/core/src/test/resources/logback-test.xml
@@ -16,12 +16,8 @@
-
-
-
+
-
-
diff --git a/openapi/pom.xml b/openapi/pom.xml
index 1758cea..f4ea1ef 100644
--- a/openapi/pom.xml
+++ b/openapi/pom.xml
@@ -114,6 +114,7 @@
org.zalando
jackson-datatype-money
1.1.1
+ test
diff --git a/openapi/src/main/java/io/sinistral/proteus/openapi/jaxrs2/Reader.java b/openapi/src/main/java/io/sinistral/proteus/openapi/jaxrs2/Reader.java
index b3e3d7d..69522a4 100644
--- a/openapi/src/main/java/io/sinistral/proteus/openapi/jaxrs2/Reader.java
+++ b/openapi/src/main/java/io/sinistral/proteus/openapi/jaxrs2/Reader.java
@@ -13,7 +13,6 @@
import com.fasterxml.jackson.databind.introspect.AnnotatedMethod;
import com.fasterxml.jackson.databind.introspect.AnnotatedParameter;
import com.fasterxml.jackson.databind.type.TypeFactory;
-import io.sinistral.proteus.openapi.models.MoneyModelConverter;
import io.sinistral.proteus.server.ServerRequest;
import io.sinistral.proteus.server.ServerResponse;
import io.swagger.v3.core.converter.AnnotatedType;
@@ -1374,19 +1373,11 @@ else if (classType.getRawClass().isAssignableFrom(CompletableFuture.class))
}
}
- ModelConverters converters = ModelConverters.getInstance();
-
- converters.addConverter(new ServerModelResolver());
- converters.addConverter(new MoneyModelConverter());
-
-
- ResolvedSchema resolvedSchema = converters
+ ResolvedSchema resolvedSchema = ModelConverters.getInstance()
.resolveAsResolvedSchema(new AnnotatedType(returnType).resolveAsRef(true).jsonViewAnnotation(jsonViewAnnotation));
if (resolvedSchema.schema != null)
{
- System.out.println("resolvedSchema: " + resolvedSchema.schema);
-
Schema returnTypeSchema = resolvedSchema.schema;
Content content = new Content();
MediaType mediaType = new MediaType().schema(returnTypeSchema);
diff --git a/openapi/src/main/java/io/sinistral/proteus/openapi/jaxrs2/ServerModelResolver.java b/openapi/src/main/java/io/sinistral/proteus/openapi/jaxrs2/ServerModelResolver.java
index 0d364f5..b5981c2 100644
--- a/openapi/src/main/java/io/sinistral/proteus/openapi/jaxrs2/ServerModelResolver.java
+++ b/openapi/src/main/java/io/sinistral/proteus/openapi/jaxrs2/ServerModelResolver.java
@@ -8,15 +8,12 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.introspect.Annotated;
import com.fasterxml.jackson.databind.type.TypeFactory;
-import io.sinistral.proteus.openapi.models.MoneyModelConverter;
import io.sinistral.proteus.server.ServerResponse;
import io.swagger.v3.core.converter.AnnotatedType;
import io.swagger.v3.core.converter.ModelConverter;
import io.swagger.v3.core.converter.ModelConverterContext;
import io.swagger.v3.core.util.Json;
import io.swagger.v3.oas.models.media.Schema;
-import org.javamoney.moneta.Money;
-import org.zalando.jackson.datatype.money.MoneyModule;
import java.io.File;
import java.lang.annotation.Annotation;
@@ -33,19 +30,9 @@ public class ServerModelResolver extends io.swagger.v3.core.jackson.ModelResolve
{
private static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(ServerModelResolver.class.getCanonicalName());
- static final ObjectMapper mapper = Json.mapper();
-
- static
- {
- mapper.registerModule(new MoneyModule());
- }
-
public ServerModelResolver()
{
- super(mapper);
-
-
- System.out.println("not from super");
+ super(Json.mapper());
}
/**
@@ -53,8 +40,7 @@ public ServerModelResolver()
*/
public ServerModelResolver(ObjectMapper mapper)
{
- super(ServerModelResolver.mapper);
-
+ super(mapper);
}
/*
@@ -72,7 +58,6 @@ public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context
if ((rawClass != null) &&!resolvedType.isPrimitive())
{
- // log.debug("resolvedType in " + resolvedType);
if (rawClass.isAssignableFrom(ServerResponse.class))
{
resolvedType = classType.containedType(0);
@@ -83,25 +68,18 @@ else if (rawClass.isAssignableFrom(CompletableFuture.class))
if (futureCls.isAssignableFrom(ServerResponse.class))
{
- // log.debug("class is assignable from ServerResponse");
final JavaType futureType = TypeFactory.defaultInstance().constructType(classType.containedType(0));
resolvedType = futureType.containedType(0);
}
else
{
- // log.debug("class is NOT assignable from ServerResponse");
resolvedType = classType.containedType(0);
}
}
if (resolvedType != null)
{
-// if (resolvedType.getTypeName().contains("org.javamoney.moneta.Money"))
-// {
-// resolvedType = TypeFactory.defaultInstance().constructFromCanonical(Money.class.getName());
-// }
-
if (resolvedType.getTypeName().contains("java.lang.Void"))
{
resolvedType = TypeFactory.defaultInstance().constructFromCanonical(Void.class.getName());
@@ -133,30 +111,12 @@ else if (resolvedType.getTypeName().contains("Optional"))
annotatedType.setType(resolvedType);
- // log.debug("resolvedType out " + resolvedType);
}
}
try {
-
- // log.info("Processing " + annotatedType + " " + classType + " " + annotatedType.getName());
-
- if(annotatedType.getType().getTypeName().contains("org.javamoney.moneta.Money"))
- {
- MoneyModelConverter.MoneySchema schema = new MoneyModelConverter.MoneySchema();
-
- context.defineModel("money",schema);
-
- return schema;
- }
- else {
-
- Schema schema = super.resolve(annotatedType, context, next);
-
- return schema;
- }
-
+ return super.resolve(annotatedType, context, next);
} catch (Exception e) {
diff --git a/openapi/src/main/java/io/sinistral/proteus/openapi/jaxrs2/ServerParameterExtension.java b/openapi/src/main/java/io/sinistral/proteus/openapi/jaxrs2/ServerParameterExtension.java
index 56e9efb..2ba39a5 100644
--- a/openapi/src/main/java/io/sinistral/proteus/openapi/jaxrs2/ServerParameterExtension.java
+++ b/openapi/src/main/java/io/sinistral/proteus/openapi/jaxrs2/ServerParameterExtension.java
@@ -4,8 +4,6 @@
*/
package io.sinistral.proteus.openapi.jaxrs2;
-import org.zalando.jackson.datatype.money.MoneyModule;
-
import com.fasterxml.jackson.annotation.JsonView;
import com.fasterxml.jackson.databind.BeanDescription;
import com.fasterxml.jackson.databind.JavaType;
@@ -24,10 +22,19 @@
import io.swagger.v3.oas.models.parameters.Parameter;
import org.apache.commons.lang3.StringUtils;
-import javax.ws.rs.*;
+import javax.ws.rs.BeanParam;
+import javax.ws.rs.CookieParam;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.MatrixParam;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.QueryParam;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
/**
* @author jbauer
@@ -43,11 +50,6 @@ public class ServerParameterExtension extends AbstractOpenAPIExtension
final static ObjectMapper mapper = Json.mapper();
- static
- {
- mapper.registerModule(new MoneyModule());
- }
-
@Override
public ResolvedParameter extractParameters(List annotations, Type type, Set typesToSkip, Components components, javax.ws.rs.Consumes classConsumes,
javax.ws.rs.Consumes methodConsumes, boolean includeRequestBody, JsonView jsonViewAnnotation, Iterator chain)
diff --git a/openapi/src/main/java/io/sinistral/proteus/openapi/services/OpenAPIService.java b/openapi/src/main/java/io/sinistral/proteus/openapi/services/OpenAPIService.java
index 0d5aeeb..c3daba8 100644
--- a/openapi/src/main/java/io/sinistral/proteus/openapi/services/OpenAPIService.java
+++ b/openapi/src/main/java/io/sinistral/proteus/openapi/services/OpenAPIService.java
@@ -1,55 +1,17 @@
package io.sinistral.proteus.openapi.services;
-import java.io.File;
-import java.io.InputStream;
-
-import java.net.URL;
-
-import java.nio.ByteBuffer;
-import java.nio.charset.Charset;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.StandardCopyOption;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.CompletableFuture;
-import java.util.function.Supplier;
-import java.util.jar.JarFile;
-import java.util.stream.Collectors;
-
-import javax.ws.rs.HttpMethod;
-import javax.ws.rs.core.MediaType;
-
-import io.sinistral.proteus.openapi.jaxrs2.Reader;
-import io.sinistral.proteus.openapi.jaxrs2.ServerModelResolver;
-import io.sinistral.proteus.openapi.jaxrs2.ServerParameterExtension;
-import io.sinistral.proteus.openapi.models.MoneyModelConverter;
-import io.sinistral.proteus.services.DefaultService;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
-
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.google.inject.name.Named;
-
import com.typesafe.config.Config;
-
+import io.sinistral.proteus.openapi.jaxrs2.Reader;
+import io.sinistral.proteus.openapi.jaxrs2.ServerParameterExtension;
import io.sinistral.proteus.server.endpoints.EndpointInfo;
-
+import io.sinistral.proteus.services.DefaultService;
import io.swagger.v3.core.util.Json;
import io.swagger.v3.core.util.Yaml;
import io.swagger.v3.jaxrs2.ext.OpenAPIExtensions;
@@ -62,7 +24,6 @@
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.security.SecurityScheme;
import io.swagger.v3.oas.models.servers.Server;
-
import io.undertow.server.HandlerWrapper;
import io.undertow.server.HttpServerExchange;
import io.undertow.server.RoutingHandler;
@@ -72,6 +33,31 @@
import io.undertow.util.CanonicalPathUtils;
import io.undertow.util.Headers;
import io.undertow.util.Methods;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.HttpMethod;
+import javax.ws.rs.core.MediaType;
+import java.io.File;
+import java.io.InputStream;
+import java.net.URL;
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+import java.util.function.Supplier;
+import java.util.jar.JarFile;
+import java.util.stream.Collectors;
/**
* A service for generating and serving an OpenAPI v3 spec and ui.
@@ -268,7 +254,7 @@ protected void generateSpec() throws Exception
SwaggerConfiguration config = new SwaggerConfiguration().resourceClasses(classes.stream().map(Class::getName).collect(Collectors.toSet())).openAPI(openApi);
- config.setModelConverterClassess(new HashSet<>(Arrays.asList(ServerModelResolver.class.getName())));
+ config.setModelConverterClassess(new HashSet<>( openAPIConfig.getStringList("converters") ));
OpenApiContext ctx = new GenericOpenApiContext().openApiConfiguration(config)
.openApiReader(new Reader(config))
diff --git a/openapi/src/test/java/io/sinistral/proteus/openapi/test/controllers/OpenAPITests.java b/openapi/src/test/java/io/sinistral/proteus/openapi/test/controllers/OpenAPITests.java
index 9ddefb8..4796233 100644
--- a/openapi/src/test/java/io/sinistral/proteus/openapi/test/controllers/OpenAPITests.java
+++ b/openapi/src/test/java/io/sinistral/proteus/openapi/test/controllers/OpenAPITests.java
@@ -148,25 +148,17 @@ public ServerResponse> genericSet( ServerRequest request, @QueryParam
@Operation(description = "Money type endpoint" )
public ServerResponse getMoney(ServerRequest request ) throws Exception
{
- return response( Money.of(100.0,"USD") ).applicationJson();
+ return response( Money.of(123.23,"USD") ).applicationJson();
}
- @GET
- @Path("types/pojo2")
- @Produces((MediaType.APPLICATION_JSON))
- @Operation(description = "Money type endpoint" )
- public ServerResponse getPojo2(ServerRequest request ) throws Exception
- {
- return response( new Pojo(100L,"USD") ).applicationJson();
- }
@GET
@Path("types/pojo")
@Produces((MediaType.APPLICATION_JSON))
- @Operation(description = "Money type endpoint" )
+ @Operation(description = "Pojo type endpoint" )
public ServerResponse getPojo(ServerRequest request ) throws Exception
{
- return response( new Pojo(100L,"USD") ).applicationJson();
+ return response( new Pojo(100L,"John Doe") ).applicationJson();
}
@POST
diff --git a/openapi/src/main/java/io/sinistral/proteus/openapi/models/MoneyModelConverter.java b/openapi/src/test/java/io/sinistral/proteus/openapi/test/converters/MoneyModelConverter.java
similarity index 73%
rename from openapi/src/main/java/io/sinistral/proteus/openapi/models/MoneyModelConverter.java
rename to openapi/src/test/java/io/sinistral/proteus/openapi/test/converters/MoneyModelConverter.java
index f37539e..b4c25fe 100644
--- a/openapi/src/main/java/io/sinistral/proteus/openapi/models/MoneyModelConverter.java
+++ b/openapi/src/test/java/io/sinistral/proteus/openapi/test/converters/MoneyModelConverter.java
@@ -1,4 +1,4 @@
-package io.sinistral.proteus.openapi.models;
+package io.sinistral.proteus.openapi.test.converters;
import com.fasterxml.jackson.databind.JavaType;
@@ -21,6 +21,8 @@
public class MoneyModelConverter implements ModelConverter
{
+ private final Schema schema = new MoneySchema();
+
@Override
public Schema resolve(AnnotatedType type, ModelConverterContext context, Iterator chain) {
@@ -28,39 +30,44 @@ public Schema resolve(AnnotatedType type, ModelConverterContext context, Iterato
if(_type != null && (_type.getRawClass().equals(Money.class)))
{
- return new MoneySchema();
+ context.defineModel("Money",schema, type, null);
+
+ return schema;
}
if (type.getType() instanceof Class>) {
- System.out.println("MoneyModelConverter resolving class: " + ((Class) type.getType()).getName());
-
Class> cls = (Class>) type.getType();
if(cls.isAssignableFrom(Money.class))
{
- return new MoneySchema();
+ context.defineModel("Money",schema, type, null);
+
+ return schema;
}
}
else if(type.getType().getTypeName().equals("[simple type, class org.javamoney.moneta.Money]"))
{
- System.out.println("is org.javamoney.moneta.Money");
- return new MoneySchema();
+ context.defineModel("Money",schema, type, null);
+
+ return schema;
}
else if (type.isSchemaProperty()) {
+
_type = Json.mapper().constructType(type.getType());
if (_type != null) {
Class> cls = _type.getRawClass();
if (Money.class.isAssignableFrom(cls)) {
- return new MoneySchema();
+
+ context.defineModel("Money",schema, type, null);
+
+ return schema;
}
}
}
if (chain.hasNext()) {
- System.out.println("skipped resolving " + _type);
-
return chain.next().resolve(type, context, chain);
}
@@ -73,13 +80,13 @@ public static class MoneySchema extends Schema
{
private String _type = "object";
- private String _$ref = null;// "#/components/schemas/Money";
+ private String _$ref = null;
private String _description = "A monetary amount";
- private Map _properties = ImmutableMap.of("number",new NumberSchema(),"currency",new StringSchema());
+ private Map _properties = ImmutableMap.of("amount",new NumberSchema(),"currency",new StringSchema());
- private List _required = Arrays.asList("number","currency");
+ private List _required = Arrays.asList("amount","currency");
public MoneySchema()
{
@@ -89,6 +96,7 @@ public MoneySchema()
super.set$ref(_$ref);
super.description(_description);
super.properties(_properties);
+ super.required(_required);
}
@Override
@@ -117,6 +125,7 @@ public boolean equals(java.lang.Object o)
MoneySchema MoneySchema = (MoneySchema) o;
return Objects.equals(this._type, MoneySchema._type) &&
Objects.equals(this._properties, MoneySchema._properties) &&
+ Objects.equals(this._description, MoneySchema._description) &&
super.equals(o);
}
@@ -126,21 +135,6 @@ public int hashCode()
return Objects.hash(_type, _properties, super.hashCode());
}
-// @Override
-// public String toString()
-// {
-// StringBuilder sb = new StringBuilder();
-// sb.append("class MoneySchema {\n");
-// sb.append(" ").append(toIndentedString(super.toString())).append("\n");
-// sb.append(" title: ").append(toIndentedString(getTitle())).append("\n");
-// sb.append(" type: ").append(toIndentedString(_type)).append("\n");
-// sb.append(toIndentedString(_properties.toString())).append("\n");
-// sb.append(" }").append("\n");
-//
-// sb.append("}");
-// return sb.toString();
-// }
-
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
diff --git a/openapi/src/test/java/io/sinistral/proteus/openapi/test/modules/JacksonModule.java b/openapi/src/test/java/io/sinistral/proteus/openapi/test/modules/JacksonModule.java
new file mode 100644
index 0000000..4bf0036
--- /dev/null
+++ b/openapi/src/test/java/io/sinistral/proteus/openapi/test/modules/JacksonModule.java
@@ -0,0 +1,35 @@
+package io.sinistral.proteus.openapi.test.modules;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
+import com.fasterxml.jackson.module.afterburner.AfterburnerModule;
+import com.google.inject.AbstractModule;
+import com.google.inject.Singleton;
+import org.zalando.jackson.datatype.money.MoneyModule;
+
+@Singleton
+public class JacksonModule extends AbstractModule
+{
+
+ @Override
+ protected void configure()
+ {
+
+ ObjectMapper objectMapper = new ObjectMapper();
+
+ objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ objectMapper.configure(DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT, true);
+ objectMapper.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true);
+ objectMapper.configure(DeserializationFeature.EAGER_DESERIALIZER_FETCH,true);
+ objectMapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
+ objectMapper.configure(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS, true);
+
+ objectMapper.registerModule(new MoneyModule())
+ .registerModule(new AfterburnerModule())
+ .registerModule(new Jdk8Module());
+
+ this.bind(ObjectMapper.class).toInstance(objectMapper);
+
+ }
+}
\ No newline at end of file
diff --git a/openapi/src/test/java/io/sinistral/proteus/openapi/test/server/OpenAPIDefaultServer.java b/openapi/src/test/java/io/sinistral/proteus/openapi/test/server/OpenAPIDefaultServer.java
index d22cac3..fbb6e1d 100644
--- a/openapi/src/test/java/io/sinistral/proteus/openapi/test/server/OpenAPIDefaultServer.java
+++ b/openapi/src/test/java/io/sinistral/proteus/openapi/test/server/OpenAPIDefaultServer.java
@@ -73,6 +73,7 @@ private static void runInternal(final RunNotifier notifier)
final ProteusApplication app = new ProteusApplication();
app.addService(OpenAPIService.class);
+
app.addService(AssetsService.class);
app.addController(OpenAPITests.class);
diff --git a/openapi/src/test/java/io/sinistral/proteus/openapi/test/server/TestOpenAPIControllerEndpoints.java b/openapi/src/test/java/io/sinistral/proteus/openapi/test/server/TestOpenAPIControllerEndpoints.java
index 7f003ce..9961e44 100644
--- a/openapi/src/test/java/io/sinistral/proteus/openapi/test/server/TestOpenAPIControllerEndpoints.java
+++ b/openapi/src/test/java/io/sinistral/proteus/openapi/test/server/TestOpenAPIControllerEndpoints.java
@@ -16,10 +16,7 @@
import java.util.stream.LongStream;
import static io.restassured.RestAssured.when;
-
-/*
- * import static io.restassured.RestAssured.*; import static io.restassured.matcher.RestAssuredMatchers.*; import static org.hamcrest.Matchers.*;
- */
+import static org.hamcrest.CoreMatchers.equalTo;
/**
* @author jbauer
@@ -61,22 +58,19 @@ public void setUp()
@Test
public void testOpenAPIDocs()
{
- when().get("openapi.yaml").then().log().all().statusCode(200);
+ when().get("openapi.yaml").then().statusCode(200);
}
+ @Test
public void testPojoType()
{
- when().get("tests/types/pojo").then().log().all().statusCode(200);
- }
-
- @Test public void testPojoType2()
- {
- when().get("tests/types/pojo2").then().log().all().statusCode(200);
+ when().get("tests/types/pojo").then().statusCode(200).body("id", equalTo(100),"name", equalTo("John Doe"));
}
+ @Test
public void testMoneyType()
{
- when().get("tests/types/money").then().log().all().statusCode(200);
+ when().get("tests/types/money").then().statusCode(200).body("amount", equalTo(123.23f),"currency", equalTo("USD"));
}
diff --git a/openapi/src/test/java/io/sinistral/proteus/test/controllers/Tests.java b/openapi/src/test/java/io/sinistral/proteus/test/controllers/Tests.java
deleted file mode 100644
index 6616627..0000000
--- a/openapi/src/test/java/io/sinistral/proteus/test/controllers/Tests.java
+++ /dev/null
@@ -1,287 +0,0 @@
-/**
- *
- */
-package io.sinistral.proteus.test.controllers;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.io.Files;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import io.sinistral.proteus.annotations.Blocking;
-import io.sinistral.proteus.server.ServerRequest;
-import io.sinistral.proteus.server.ServerResponse;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.security.SecurityRequirement;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import io.swagger.v3.oas.annotations.tags.Tags;
-import io.undertow.server.HttpServerExchange;
-import org.javamoney.moneta.Money;
-
-import javax.ws.rs.*;
-import javax.ws.rs.core.MediaType;
-import java.io.File;
-import java.nio.ByteBuffer;
-import java.sql.Timestamp;
-import java.time.Instant;
-import java.util.*;
-import java.util.concurrent.CompletableFuture;
-
-import static io.sinistral.proteus.server.ServerResponse.response;
-
-/**
- * @author jbauer
- *
- */
-
-@Tags({@Tag(name = "tests")})
-@Path("/tests")
-@Produces((MediaType.APPLICATION_JSON))
-@Consumes((MediaType.MEDIA_TYPE_WILDCARD))
-@Singleton
-public class Tests
-{
- private static final ByteBuffer buffer;
- static {
- String message = "Hello, World!";
- byte[] messageBytes = message.getBytes(java.nio.charset.StandardCharsets.US_ASCII);
- buffer = ByteBuffer.allocateDirect(messageBytes.length);
- buffer.put(messageBytes);
- buffer.flip();
- }
-
- @Inject
- protected ObjectMapper objectMapper;
-
-
- @GET
- @Path("exchange/plaintext")
- @Produces((MediaType.TEXT_PLAIN))
- @Operation(description = "Plaintext endpoint" )
- public void exchangePlaintext(HttpServerExchange exchange)
- {
- response("Hello, World!").textPlain().send(exchange);
-
- }
-
-
- @GET
- @Path("response/plaintext")
- @Produces((MediaType.TEXT_PLAIN))
- @Operation(description = "Plaintext endpoint" )
- public ServerResponse responsePlaintext(ServerRequest request)
- {
- return response("Hello, World!").textPlain();
-
- }
-
- @GET
- @Path("response/future/map")
- @Operation(description = "Future map endpoint" )
- public CompletableFuture>> responseFutureMap( ServerRequest request )
- {
- Map map = ImmutableMap.of("message", "success");
- return CompletableFuture.completedFuture(response( map ).applicationJson());
- }
-
- @GET
- @Path("response/map")
- @Operation(description = "Map endpoint" )
- public ServerResponse