@Test public void exportApiToSwaggerJSON() { Set<Resource> resources = api.getResources(); Resource resource = resources.iterator().next(); String path = resource.getOperations().get(0).getPath(); Swagger swagger = swaggerService.exportApiToSwaggerJSON(api); String basePath = swagger.getBasePath(); String host = swagger.getHost(); List<Tag> tags = swagger.getTags(); Tag tag = tags.get(0); String tagName = tag.getName(); Map<String, Path> paths = swagger.getPaths(); Path pathSwagger = paths.get(path); assertNotNull(pathSwagger); io.swagger.models.Operation get = pathSwagger.getGet(); assertEquals(api.getBasePath(), basePath); assertEquals(api.getEnvironments().get(0).getInboundURL(), host); assertEquals(tagName, resource.getName()); assertTrue(get.getTags().contains(tagName)); }
public Swagger exportApiToSwaggerJSON(Api api) { Swagger swagger = new Swagger(); swagger.setSwagger("2.0"); swagger.setBasePath(api.getBasePath()); swagger.setInfo(getInfoByApi(api)); Optional<Environment> optionalEnvironment = api.getEnvironments().stream().findFirst(); optionalEnvironment.ifPresent(environment -> swagger.setHost(environment.getInboundURL())); swagger.setTags(getTagsByApi(api)); swagger.setPaths(getPathsByApi(api)); swagger.setDefinitions(new HashMap<>()); swagger.setConsumes(new ArrayList<>()); return swagger; }
SwaggerService { public Swagger exportApiToSwaggerJSON(Api api) { Swagger swagger = new Swagger(); swagger.setSwagger("2.0"); swagger.setBasePath(api.getBasePath()); swagger.setInfo(getInfoByApi(api)); Optional<Environment> optionalEnvironment = api.getEnvironments().stream().findFirst(); optionalEnvironment.ifPresent(environment -> swagger.setHost(environment.getInboundURL())); swagger.setTags(getTagsByApi(api)); swagger.setPaths(getPathsByApi(api)); swagger.setDefinitions(new HashMap<>()); swagger.setConsumes(new ArrayList<>()); return swagger; } }
SwaggerService { public Swagger exportApiToSwaggerJSON(Api api) { Swagger swagger = new Swagger(); swagger.setSwagger("2.0"); swagger.setBasePath(api.getBasePath()); swagger.setInfo(getInfoByApi(api)); Optional<Environment> optionalEnvironment = api.getEnvironments().stream().findFirst(); optionalEnvironment.ifPresent(environment -> swagger.setHost(environment.getInboundURL())); swagger.setTags(getTagsByApi(api)); swagger.setPaths(getPathsByApi(api)); swagger.setDefinitions(new HashMap<>()); swagger.setConsumes(new ArrayList<>()); return swagger; }  }
SwaggerService { public Swagger exportApiToSwaggerJSON(Api api) { Swagger swagger = new Swagger(); swagger.setSwagger("2.0"); swagger.setBasePath(api.getBasePath()); swagger.setInfo(getInfoByApi(api)); Optional<Environment> optionalEnvironment = api.getEnvironments().stream().findFirst(); optionalEnvironment.ifPresent(environment -> swagger.setHost(environment.getInboundURL())); swagger.setTags(getTagsByApi(api)); swagger.setPaths(getPathsByApi(api)); swagger.setDefinitions(new HashMap<>()); swagger.setConsumes(new ArrayList<>()); return swagger; }  Swagger exportApiToSwaggerJSON(Api api); Api importApiFromSwaggerJSON(Api api, String swaggerAsString, boolean override); }
SwaggerService { public Swagger exportApiToSwaggerJSON(Api api) { Swagger swagger = new Swagger(); swagger.setSwagger("2.0"); swagger.setBasePath(api.getBasePath()); swagger.setInfo(getInfoByApi(api)); Optional<Environment> optionalEnvironment = api.getEnvironments().stream().findFirst(); optionalEnvironment.ifPresent(environment -> swagger.setHost(environment.getInboundURL())); swagger.setTags(getTagsByApi(api)); swagger.setPaths(getPathsByApi(api)); swagger.setDefinitions(new HashMap<>()); swagger.setConsumes(new ArrayList<>()); return swagger; }  Swagger exportApiToSwaggerJSON(Api api); Api importApiFromSwaggerJSON(Api api, String swaggerAsString, boolean override);  }