@Override public void apply(Swagger swagger) { if (swagger.getDefinitions() != null) { swagger.setDefinitions(new TreeMap<>(swagger.getDefinitions())); } if (swagger.getPaths() != null) { swagger.setPaths(new TreeMap<>(swagger.getPaths())); } } }
public void apply(Swagger swagger) { swagger.setHost("newHostName"); //<1> swagger.basePath("newBasePath"); Map<String, Path> paths = swagger.getPaths(); //<2> paths.remove("/remove"); swagger.setPaths(paths); } }
protected Swagger removeBasePathFromEndpoints(Swagger swagger, boolean removeBasePathFromEndpoints) { Swagger result = swagger; if (!removeBasePathFromEndpoints) { return result; } String basePath = swagger.getBasePath(); if (isEmpty(basePath)) { return result; } Map<String, Path> oldPathMap = result.getPaths(); Map<String, Path> newPathMap = new HashMap<String, Path>(); for (Map.Entry<String, Path> entry: oldPathMap.entrySet()) { newPathMap.put(entry.getKey().replace(basePath, ""), entry.getValue()); } result.setPaths(newPathMap); return result; }
public Swagger paths(Map<String, Path> paths) { this.setPaths(paths); return this; }
private byte[] writeDynamicResource(InputStream is) throws IOException { String str = CharStreams.toString(new InputStreamReader(is, Charsets.UTF_8)); Swagger swagger = new SwaggerParser().parse(str); // set the resource listing tag Tag dynamic = new Tag(); dynamic.setName("dynamic"); dynamic.setDescription("Dynamic Cypher resources"); swagger.addTag(dynamic); // add resources to the path Map<String,Path> paths = swagger.getPaths(); paths.putAll(configuration.getCypherResources()); Map<String,Path> sorted = new LinkedHashMap<>(); List<String> keys = new ArrayList<>(); keys.addAll(paths.keySet()); Collections.sort(keys); for (String key : keys) { sorted.put(key, paths.get(key)); } swagger.setPaths(sorted); // return updated swagger JSON return Json.pretty(swagger).getBytes(); }
/** * This is a generateSwagger * * @return String */ public String generateSwagger() { Swagger swagger = new Swagger().info(getInfo()); swagger.setPaths(getPaths()); swagger.setDefinitions(getDefinition()); return swagger.toString(); }
.sorted(Comparator.comparing(Map.Entry::getKey)) .collect(Collectors.toList()); swagger.setPaths(new LinkedHashMap<>()); for (Map.Entry<String, Path> entry : paths) { swagger.path(entry.getKey(), entry.getValue());
combined.setPaths(paths);
swagger.setPaths(new TreeMap<>()); swagger.setDefinitions(new TreeMap<>()); return swagger;
/** * This method will convert ballerina @Service to swaggers @Swagger object. * * @param service ballerina @Service object to be map to swagger definition * @param swagger Swagger model to populate * @return Swagger object which represent current service. */ public Swagger convertServiceToSwagger(BLangService service, Swagger swagger) { // Setting default values. swagger.setBasePath('/' + service.getName().getValue()); this.parseServiceInfoAnnotationAttachment(service, swagger); this.parseConfigAnnotationAttachment(service, swagger); SwaggerResourceMapper resourceMapper = new SwaggerResourceMapper(swagger, this.httpAlias, this.swaggerAlias); swagger.setPaths(resourceMapper.convertResourceToPath(service.getResources())); return swagger; }
boolean _tripleEquals = (_paths == null); if (_tripleEquals) { swagger.setPaths(Collections.<String, Path>emptyMap());
getLog().info("API-GENERATION DISABLED ..."); System.setProperty("models", ""); swagger.setPaths(new HashMap<String, Path>(0));
@Override public void swagger(Swagger swagger) { swagger.setSchemes(fillList(swagger.getSchemes())); swagger.setConsumes(fillList(swagger.getConsumes())); swagger.setProduces(fillList(swagger.getProduces())); swagger.setPaths(fillMap(swagger.getPaths())); swagger.setDefinitions(fillMap(swagger.getDefinitions())); swagger.setParameters(fillMap(swagger.getParameters())); swagger.setResponses(fillMap(swagger.getResponses())); swagger.setSecurityDefinitions(fillMap(swagger.getSecurityDefinitions())); swagger.setSecurity(fillList(swagger.getSecurity())); swagger.setTags(fillList(swagger.getTags())); }