use of io.gravitee.definition.jackson.datatype.GraviteeMapper in project gravitee-management-rest-api by gravitee-io.
the class ServiceConfiguration method objectMapper.
@Bean
public ObjectMapper objectMapper() {
ObjectMapper objectMapper = new GraviteeMapper();
PropertyFilter apiMembershipTypeFilter = new ApiPermissionFilter();
objectMapper.setFilterProvider(new SimpleFilterProvider(Collections.singletonMap("apiMembershipTypeFilter", apiMembershipTypeFilter)));
return objectMapper;
}
use of io.gravitee.definition.jackson.datatype.GraviteeMapper in project gravitee-gateway by gravitee-io.
the class ApiDeployerStatement method loadApi.
private Api loadApi(String apiDescriptorPath) throws Exception {
URL jsonFile = ApiDeployerStatement.class.getResource(apiDescriptorPath);
Api api = new GraviteeMapper().readValue(jsonFile, Api.class);
if (ApiLoaderInterceptor.class.isAssignableFrom(target.getClass())) {
ApiLoaderInterceptor loader = (ApiLoaderInterceptor) target;
loader.before(api);
}
boolean enhanceHttpPort = target.getClass().getAnnotation(ApiDescriptor.class).enhanceHttpPort();
if (enhanceHttpPort) {
List<Endpoint> endpoints = new ArrayList<>(api.getProxy().getEndpoints());
List<Integer> bindPorts = SocketUtils.getBindPorts();
for (int i = 0; i < bindPorts.size(); i++) {
int port = SocketUtils.getBindPorts().get(i);
if (i < endpoints.size()) {
Endpoint edpt = endpoints.get(i);
URL target = new URL(edpt.getTarget());
URL newTarget = new URL(target.getProtocol(), target.getHost(), port, target.getFile());
edpt.setTarget(newTarget.toString());
edpt.setName(UUID.random().toString());
} else {
// Use the first defined endpoint as reference
HttpEndpoint first = (HttpEndpoint) endpoints.get(0);
URL target = new URL(first.getTarget());
URL newTarget = new URL(target.getProtocol(), target.getHost(), port, target.getFile());
HttpEndpoint edpt = new HttpEndpoint(UUID.random().toString(), newTarget.toString());
edpt.setHttpClientOptions(first.getHttpClientOptions());
api.getProxy().getEndpoints().add(edpt);
}
}
}
if (ApiLoaderInterceptor.class.isAssignableFrom(target.getClass())) {
ApiLoaderInterceptor loader = (ApiLoaderInterceptor) target;
loader.after(api);
}
return api;
}
use of io.gravitee.definition.jackson.datatype.GraviteeMapper in project gravitee-gateway by gravitee-io.
the class LocalApiDefinitionRegistry method loadDefinition.
private Api loadDefinition(File apiDefinitionFile) throws IOException {
Api api = new GraviteeMapper().readValue(apiDefinitionFile, Api.class);
api.setId(IdGenerator.generate(api.getName()));
return api;
}
use of io.gravitee.definition.jackson.datatype.GraviteeMapper in project gravitee-gateway by gravitee-io.
the class StandaloneConfiguration method objectMapper.
@Bean
public ObjectMapper objectMapper() {
ObjectMapper mapper = new GraviteeMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
return mapper;
}
Aggregations