ApiDeclaration api = new ApiDeclaration();
Map<String,Model> models = new HashMap<String, Model>();
api.setModels(models);
ApiVersionPlugin pluginVersion = plugin.getApiVersionRegistry().getPluginForVersion(null);
api.setApiVersion(pluginVersion.getVersion().toString());
api.setSwaggerVersion("1.2");
api.setBasePath(basePath);
api.setResourcePath(String.format("/%s",plugin.getEndpointName()));
List<Api> apis = new ArrayList<Api>();
if(plugin.isMethodAllowed(HttpMethod.GET) || plugin.isMethodAllowed(HttpMethod.PUT) ||
plugin.isMethodAllowed(HttpMethod.DELETE))
{
apis.add(buildIdApi(plugin,resourceBundle));
}
if(plugin.isMethodAllowed(HttpMethod.GET) || plugin.isMethodAllowed(HttpMethod.POST))
apis.add(buildApi(plugin,resourceBundle));
TypeFactory typeFactory = objectMapper.getTypeFactory();
if(plugin.isHistoryEnabled())
{
apis.add(buildHistory(plugin,resourceBundle));
models.putAll(buildModels(String.format("%sHistoryResponse", plugin.getEndpointName()),
typeFactory.constructParametricType(HistoryResponse.class, Serializable.class, pluginVersion.getApiClass())));
}
api.setApis(apis);
models.putAll(buildModels(endpoint, typeFactory.constructType(pluginVersion.getApiClass())));
if(plugin.isMethodAllowed(HttpMethod.GET))
models.putAll(buildModels(String.format("%sEntityResponse", plugin.getEndpointName()),
typeFactory.constructParametricType(EntityResponse.class, pluginVersion.getApiClass())));
if(plugin.isMethodAllowed(HttpMethod.DELETE))
models.putAll(buildModels(String.format("%sDeleteResponse", plugin.getEndpointName()),
typeFactory.constructType(DeleteResponse.class)));