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 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); } }
HttpMethod method = HttpMethod.valueOf(req.getMethod().toUpperCase()); Route route = swaggerContext.getRouter().route(method, req.getPathInfo()); if (route != null && ! route.isImplemented()) {
@Override public void handleRequest(final HttpServerExchange exchange) throws Exception { final NormalisedPath requestPath = new ApiNormalisedPath(exchange.getRequestURI()); final Optional<NormalisedPath> maybeApiPath = SwaggerHelper.findMatchingApiPath(requestPath); if (!maybeApiPath.isPresent()) { setExchangeStatus(exchange, STATUS_INVALID_REQUEST_PATH, requestPath.normalised()); return; } final NormalisedPath swaggerPathString = maybeApiPath.get(); final Path swaggerPath = SwaggerHelper.swagger.getPath(swaggerPathString.original()); final HttpMethod httpMethod = HttpMethod.valueOf(exchange.getRequestMethod().toString()); final Operation operation = swaggerPath.getOperationMap().get(httpMethod); if (operation == null) { setExchangeStatus(exchange, STATUS_METHOD_NOT_ALLOWED); return; } // This handler can identify the swaggerOperation and endpoint only. Other info will be added by JwtVerifyHandler. final SwaggerOperation swaggerOperation = new SwaggerOperation(swaggerPathString, swaggerPath, httpMethod, operation); String endpoint = swaggerPathString.normalised() + "@" + httpMethod.toString().toLowerCase(); Map<String, Object> auditInfo = new HashMap<>(); auditInfo.put(Constants.ENDPOINT_STRING, endpoint); auditInfo.put(Constants.SWAGGER_OPERATION_STRING, swaggerOperation); exchange.putAttachment(AuditHandler.AUDIT_INFO, auditInfo); Handler.next(exchange, next); }
final Path swaggerPath = SwaggerHelper.swagger.getPath(swaggerPathString.original()); final HttpMethod httpMethod = HttpMethod.valueOf(exchange.getRequestMethod().toString()); operation = swaggerPath.getOperationMap().get(httpMethod);
if (swaggerPath == null) throw new ValidationException(Status.NOT_FOUND.getCode(), "No swagger found: " + requestPath); Operation swaggerOp = swaggerPath.getOperationMap().get(HttpMethod.valueOf(httpMethod)); if (swaggerOp == null) throw new ValidationException(Status.NOT_FOUND.getCode(), "No swagger found: " + httpMethod + " " + requestPath);