mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 11:23:58 +00:00
prepare for multiple jaxrs libraries
This commit is contained in:
parent
ffe12b0620
commit
29f928d644
@ -1 +0,0 @@
|
||||
{"library":"feign"}
|
@ -0,0 +1,44 @@
|
||||
package {{apiPackage}};
|
||||
|
||||
import com.sun.jersey.core.spi.component.ComponentContext;
|
||||
import com.sun.jersey.spi.inject.Injectable;
|
||||
import com.sun.jersey.spi.inject.PerRequestTypeInjectableProvider;
|
||||
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import javax.ws.rs.ext.Provider;
|
||||
import org.joda.time.DateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Provider
|
||||
public class JodaDateTimeProvider extends PerRequestTypeInjectableProvider<QueryParam, DateTime> {
|
||||
private final UriInfo uriInfo;
|
||||
|
||||
public JodaDateTimeProvider(@Context UriInfo uriInfo) {
|
||||
super(DateTime.class);
|
||||
this.uriInfo = uriInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Injectable<DateTime> getInjectable(final ComponentContext cc, final QueryParam a) {
|
||||
return new Injectable<DateTime>() {
|
||||
@Override
|
||||
public DateTime getValue() {
|
||||
final List<String> values = uriInfo.getQueryParameters().get(a.value());
|
||||
|
||||
if (values == null || values.isEmpty())
|
||||
return null;
|
||||
if (values.size() > 1) {
|
||||
throw new WebApplicationException(Response.status(Status.BAD_REQUEST).
|
||||
entity(a.value() + " cannot contain multiple values").build());
|
||||
}
|
||||
|
||||
return DateTime.parse(values.get(0));
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package {{apiPackage}};
|
||||
|
||||
import com.sun.jersey.core.spi.component.ComponentContext;
|
||||
import com.sun.jersey.spi.inject.Injectable;
|
||||
import com.sun.jersey.spi.inject.PerRequestTypeInjectableProvider;
|
||||
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import javax.ws.rs.ext.Provider;
|
||||
import org.joda.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
@Provider
|
||||
public class JodaLocalDateProvider extends PerRequestTypeInjectableProvider<QueryParam, LocalDate> {
|
||||
private final UriInfo uriInfo;
|
||||
|
||||
public JodaLocalDateProvider(@Context UriInfo uriInfo) {
|
||||
super(LocalDate.class);
|
||||
this.uriInfo = uriInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Injectable<LocalDate> getInjectable(final ComponentContext cc, final QueryParam a) {
|
||||
return new Injectable<LocalDate>() {
|
||||
@Override
|
||||
public LocalDate getValue() {
|
||||
final List<String> values = uriInfo.getQueryParameters().get(a.value());
|
||||
|
||||
if (values == null || values.isEmpty())
|
||||
return null;
|
||||
if (values.size() > 1) {
|
||||
throw new WebApplicationException(Response.status(Status.BAD_REQUEST).
|
||||
entity(a.value() + " cannot contain multiple values").build());
|
||||
}
|
||||
|
||||
return LocalDate.parse(values.get(0));
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package {{apiPackage}};
|
||||
|
||||
import com.sun.jersey.core.spi.component.ComponentContext;
|
||||
import com.sun.jersey.spi.inject.Injectable;
|
||||
import com.sun.jersey.spi.inject.PerRequestTypeInjectableProvider;
|
||||
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import javax.ws.rs.ext.Provider;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
@Provider
|
||||
public class LocalDateProvider extends PerRequestTypeInjectableProvider<QueryParam, LocalDate> {
|
||||
private final UriInfo uriInfo;
|
||||
|
||||
public LocalDateProvider(@Context UriInfo uriInfo) {
|
||||
super(LocalDate.class);
|
||||
this.uriInfo = uriInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Injectable<LocalDate> getInjectable(final ComponentContext cc, final QueryParam a) {
|
||||
return new Injectable<LocalDate>() {
|
||||
@Override
|
||||
public LocalDate getValue() {
|
||||
final List<String> values = uriInfo.getQueryParameters().get(a.value());
|
||||
|
||||
if (values == null || values.isEmpty())
|
||||
return null;
|
||||
if (values.size() > 1) {
|
||||
throw new WebApplicationException(Response.status(Status.BAD_REQUEST).
|
||||
entity(a.value() + " cannot contain multiple values").build());
|
||||
}
|
||||
|
||||
return LocalDate.parse(values.get(0));
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package {{apiPackage}};
|
||||
|
||||
import com.sun.jersey.core.spi.component.ComponentContext;
|
||||
import com.sun.jersey.spi.inject.Injectable;
|
||||
import com.sun.jersey.spi.inject.PerRequestTypeInjectableProvider;
|
||||
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import javax.ws.rs.ext.Provider;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Provider
|
||||
public class LocalDateTimeProvider extends PerRequestTypeInjectableProvider<QueryParam, LocalDateTime> {
|
||||
private final UriInfo uriInfo;
|
||||
|
||||
public LocalDateTimeProvider(@Context UriInfo uriInfo) {
|
||||
super(LocalDateTime.class);
|
||||
this.uriInfo = uriInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Injectable<LocalDateTime> getInjectable(final ComponentContext cc, final QueryParam a) {
|
||||
return new Injectable<LocalDateTime>() {
|
||||
@Override
|
||||
public LocalDateTime getValue() {
|
||||
final List<String> values = uriInfo.getQueryParameters().get(a.value());
|
||||
|
||||
if (values == null || values.isEmpty())
|
||||
return null;
|
||||
if (values.size() > 1) {
|
||||
throw new WebApplicationException(Response.status(Status.BAD_REQUEST).
|
||||
entity(a.value() + " cannot contain multiple values").build());
|
||||
}
|
||||
|
||||
return LocalDateTime.parse(values.get(0));
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@ -17,7 +17,7 @@ import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class AllowableValuesTest {
|
||||
|
||||
private static final String TEMPLATE_FILE = "JavaJaxRS/allowableValues.mustache";
|
||||
private static final String TEMPLATE_FILE = "JavaJaxRS/jersey1_18/allowableValues.mustache";
|
||||
private static final String PROVIDER_NAME = "operations";
|
||||
|
||||
private static String loadClassResource(Class<?> cls, String name) throws IOException {
|
||||
|
Loading…
Reference in New Issue
Block a user