Skip to content
Permalink
Browse files
passing a few more TCK
  • Loading branch information
rmannibucau committed Jul 1, 2018
1 parent 19f66f1 commit 3b09b9f9bd93b1c9c777f770e51d1d9343b238d4
Show file tree
Hide file tree
Showing 6 changed files with 166 additions and 90 deletions.
@@ -36,6 +36,7 @@
import javax.enterprise.inject.spi.CDI;
import javax.enterprise.inject.spi.Extension;
import javax.enterprise.inject.spi.ProcessBean;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.Path;
import javax.ws.rs.core.Application;

@@ -63,6 +64,7 @@ public <T> void findEndpointsAndApplication(@Observes final ProcessBean<T> event
}

public OpenAPI getOrCreateOpenAPI(final Application application) {
// todo: there are configs for that, todo: handle it
if (!application.getSingletons().isEmpty() || !application.getClasses().isEmpty()) {
return openapis.computeIfAbsent(application,
app -> createOpenApi(application.getClass(), Stream.concat(endpoints.stream().map(Bean::getBeanClass),
@@ -80,7 +82,13 @@ private OpenAPI createOpenApi(final Class<?> application, final Stream<Class<?>>
final BeanManager beanManager = current.getBeanManager();
final OpenAPI impl = current.select(DefaultLoader.class).get().loadDefaultApi();
processor.processApplication(impl, new ElementImpl(beanManager.createAnnotatedType(application)));
beans.map(beanManager::createAnnotatedType).forEach(at -> processor.processClass(impl, new ElementImpl(at),

// todo: use servlet to get the servlet mapping which is a valid deployment too
final String base = ofNullable(application.getAnnotation(ApplicationPath.class)).map(ApplicationPath::value)
.filter(it -> !"/".equals(it))
.map(it -> it.endsWith("*") ? it.substring(0, it.length() - 1) : it)
.orElse("");
beans.map(beanManager::createAnnotatedType).forEach(at -> processor.processClass(base, impl, new ElementImpl(at),
at.getMethods().stream().map(MethodElementImpl::new)));
return impl;
});
@@ -20,9 +20,11 @@
import java.util.Map;

import javax.enterprise.inject.Vetoed;
import javax.json.bind.annotation.JsonbTypeAdapter;
import javax.json.bind.annotation.JsonbTypeDeserializer;

import org.apache.geronimo.microprofile.openapi.impl.model.codec.Deserializers;
import org.apache.geronimo.microprofile.openapi.impl.model.codec.Serializers;
import org.eclipse.microprofile.openapi.models.Extensible;
import org.eclipse.microprofile.openapi.models.examples.Example;
import org.eclipse.microprofile.openapi.models.headers.Header;
@@ -239,6 +241,7 @@ public Header schema(final Schema _schema) {
}

@Override
@JsonbTypeAdapter(Serializers.HeaderStyleSerializer.class)
public Style getStyle() {
return _style;
}
@@ -44,7 +44,7 @@ public class OpenAPIImpl implements OpenAPI {

private Info _info;

private String _openapi = "3.0.0";
private String _openapi = "3.0.1";

private Paths _paths;

@@ -21,6 +21,7 @@
import javax.enterprise.inject.Vetoed;
import javax.json.bind.adapter.JsonbAdapter;

import org.eclipse.microprofile.openapi.models.headers.Header;
import org.eclipse.microprofile.openapi.models.media.Schema;
import org.eclipse.microprofile.openapi.models.parameters.Parameter;

@@ -51,6 +52,14 @@ public E adaptFromJson(final String obj) {
}
}

@Vetoed
public static class HeaderStyleSerializer extends EnumSerializer<Header.Style> implements JsonbAdapter<Header.Style, String> {

public HeaderStyleSerializer() {
super(Header.Style.class);
}
}

@Vetoed
public static class InSerializer extends EnumSerializer<Parameter.In> implements JsonbAdapter<Parameter.In, String> {

0 comments on commit 3b09b9f

Please sign in to comment.