path.set(method(route), op);
Operation.STATUS_CODE_NOT_FOUND, responseGenericError() )); path.set(Service.Action.GET.name().toLowerCase(), get);
protected void addOperationToSwagger() { if (StringUtils.isEmpty(httpMethod)) { return; } Path pathObj = swagger.getPath(path); if (pathObj == null) { pathObj = new Path(); swagger.path(path, pathObj); } HttpMethod hm = HttpMethod.valueOf(httpMethod.toUpperCase(Locale.US)); if (pathObj.getOperationMap().get(hm) != null) { throw new Error(String.format("Only allowed one default path. %s:%s", swaggerGenerator.getCls().getName(), providerMethod.getName())); } pathObj.set(httpMethod, operation); } }
protected void updatePath(String operationPath, String httpMethod, Operation operation) { if (httpMethod == null) { return; } Path path = swagger.getPath(operationPath); if (path == null) { path = new Path(); swagger.path(operationPath, path); } path.set(httpMethod, operation); }
private boolean isPathNotExist(Map<String, UriTemplate> uriTemplateMap, String securityName, Map.Entry<String, Path> entry) { Path path = entry.getValue(); String uri = entry.getKey(); path.getOperationMap().entrySet().forEach(httpMethodOperationEntry -> { if (isOperationNotExist(httpMethodOperationEntry, uri, uriTemplateMap, securityName)) { path.set(httpMethodOperationEntry.getKey().name().toLowerCase(), null); } }); return path.isEmpty(); }
private boolean isPathNotExist(Map<String, UriTemplate> uriTemplateMap, String securityName, Map.Entry<String, Path> entry) { Path path = entry.getValue(); String uri = entry.getKey(); path.getOperationMap().entrySet().forEach(httpMethodOperationEntry -> { if (isOperationNotExist(httpMethodOperationEntry, uri, uriTemplateMap, securityName)) { path.set(httpMethodOperationEntry.getKey().name().toLowerCase(), null); } }); return path.isEmpty(); }
protected void addOperationToSwagger() { if (StringUtils.isEmpty(httpMethod)) { return; } Path pathObj = swagger.getPath(path); if (pathObj == null) { pathObj = new Path(); swagger.path(path, pathObj); } HttpMethod hm = HttpMethod.valueOf(httpMethod.toUpperCase(Locale.US)); if (pathObj.getOperationMap().get(hm) != null) { throw new Error(String.format("Only allowed one default path. %s:%s", swaggerGenerator.getCls().getName(), providerMethod.getName())); } pathObj.set(httpMethod, operation); } }
private Path getNewWildCardPathObject(Path userDefinedWildCardPathObject) { Preconditions.checkNotNull( userDefinedWildCardPathObject, "userDefinedWildCardPathObject cannot be null"); Path path = new Path(); if (userDefinedWildCardPathObject.getGet() == null) { path.set("get", constructReservedOperation("Get")); } if (userDefinedWildCardPathObject.getDelete() == null) { path.set("delete", constructReservedOperation("Delete")); } if (userDefinedWildCardPathObject.getPatch() == null) { path.set("patch", constructReservedOperation("Patch")); } if (userDefinedWildCardPathObject.getPost() == null) { path.set("post", constructReservedOperation("Post")); } if (userDefinedWildCardPathObject.getPut() == null) { path.set("put", constructReservedOperation("Put")); } return path; }
private Path getNewWildCardPathObject(Path userDefinedWildCardPathObject) { Preconditions.checkNotNull( userDefinedWildCardPathObject, "userDefinedWildCardPathObject cannot be null"); Path path = new Path(); if (userDefinedWildCardPathObject.getGet() == null) { path.set("get", constructReservedOperation("Get")); } if (userDefinedWildCardPathObject.getDelete() == null) { path.set("delete", constructReservedOperation("Delete")); } if (userDefinedWildCardPathObject.getPatch() == null) { path.set("patch", constructReservedOperation("Patch")); } if (userDefinedWildCardPathObject.getPost() == null) { path.set("post", constructReservedOperation("Post")); } if (userDefinedWildCardPathObject.getPut() == null) { path.set("put", constructReservedOperation("Put")); } return path; }
/** * Resource mapper when a resource has more than 1 http method. * * @param pathMap The map with paths that should be updated. * @param resource The ballerina resource. */ private void useMultiResourceMapper(Map<String, Path> pathMap, BLangFunction resource) { List<String> httpMethods = this.getHttpMethods(resource, false); String path = this.getPath(resource); Path pathObject = new Path(); Operation operation; if (httpMethods.size() > 1) { int i = 1; for (String httpMethod : httpMethods) { //Iterate through http methods and fill path map. operation = this.convertResourceToOperation(resource, httpMethod, i).getOperation(); pathObject.set(httpMethod.toLowerCase(Locale.ENGLISH), operation); i++; } } pathMap.put(path, pathObject); }
public ExOperation mkOperation(HttpMethod method, String path) { notEmpty(path, "'path' CAN'T be null or empty!!!"); notEmpty(method, "'method' CAN'T be null or empty!!!"); synchronized (swagger) { String origPath = path; path = path.replaceAll("<[^>]+>", "").replaceAll("/:([^/]+)", "/{$1}"); // replace `/:id<[0-9]+>` with `/{id}` if (swagger.getPath(path) == null) { logger.info(">>> adding path - '" + path + "'"); swagger.path(path, new Path()); } Path pathObj = swagger.getPath(path); if (pathObj.getOperationMap().get(method) != null) { throw new IllegalArgumentException("DUPLICATED operation - " + method + " '" + path + "'"); } logger.info(">>> adding operation - " + method + " '" + path + "'"); pathObj.set(method.name().toLowerCase(), new ExOperation(this, method, path)); implemented.put(entry(method, path), true); // set implemented by default String prevPath = origPaths.put(entry(method, path), origPath); if (prevPath != null) throw new IllegalArgumentException( "`" + path + "` was repeatedly defined by `" + prevPath + "` and `" + origPath + "`!!!"); return (ExOperation) pathObj.getOperationMap().get(method); } }
path.set(route.getRequestMethod().toLowerCase(), operation); log.debug("Add {} {} => {}", route.getRequestMethod(), operationPath, Util.toString(method));
if (stringPathMap.containsKey(uriTemplateString)) { Path path = stringPathMap.get(uriTemplateString); path.set(uriTemplate.getHttpVerb().toLowerCase(), operation); } else { Path path = new Path(); path.set(uriTemplate.getHttpVerb().toLowerCase(), operation); stringPathMap.put(uriTemplateString, path);
if (stringPathMap.containsKey(uriTemplateString)) { Path path = stringPathMap.get(uriTemplateString); path.set(uriTemplate.getHttpVerb().toLowerCase(), operation); } else { Path path = new Path(); path.set(uriTemplate.getHttpVerb().toLowerCase(), operation); stringPathMap.put(uriTemplateString, path);
swagger.path(parsedPath, path); path.set(httpMethod.toLowerCase(), operation);
swagger.path(parsedPath, path); path.set(httpMethod.toLowerCase(), operation);
path.set(v.getHttpVerb().toLowerCase(), operationTocCreate);
path.set(v.getHttpVerb().toLowerCase(), operationTocCreate);