Java Code Examples for io.swagger.annotations.Api#tags()

The following examples show how to use io.swagger.annotations.Api#tags() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Reader.java    From dorado with Apache License 2.0 6 votes vote down vote up
protected Set<String> extractTags(Api api) {
	Set<String> output = new LinkedHashSet<String>();

	boolean hasExplicitTags = false;
	for (String tag : api.tags()) {
		if (!"".equals(tag)) {
			hasExplicitTags = true;
			output.add(tag);
		}
	}
	if (!hasExplicitTags) {
		// derive tag from api path + description
		String tagString = api.value().replace("/", "");
		if (!"".equals(tagString)) {
			output.add(tagString);
		}
	}
	return output;
}
 
Example 2
Source File: ExtendedSwaggerReader.java    From msf4j with Apache License 2.0 6 votes vote down vote up
protected Set<String> extractTags(Api api) {
    Set<String> output = new LinkedHashSet<>();

    boolean hasExplicitTags = false;
    for (String tag : api.tags()) {
        if (!"".equals(tag)) {
            hasExplicitTags = true;
            output.add(tag);
        }
    }
    if (!hasExplicitTags) {
        // derive tag from api path + description
        String tagString = api.value().replace("/", "");
        if (!"".equals(tagString)) {
            output.add(tagString);
        }
    }
    return output;
}
 
Example 3
Source File: ApiInfo.java    From swagger-more with Apache License 2.0 5 votes vote down vote up
private void readApi() {
    Api api = findAnnotation(Api.class);
    if (nonNull(api)) {
        hidden |= api.hidden();
        for (String tag : api.tags()) {
            if (!StringUtils.isEmpty(tag)) {
                this.tag = tag;
            }
        }
    }
}
 
Example 4
Source File: DefaultEndPointPlugin.java    From BlogManagePlatform with Apache License 2.0 5 votes vote down vote up
private String resolveApiName(OperationContext context) {
	Api api = context.findControllerAnnotation(Api.class).orNull();
	if (api != null) {
		return api.tags()[0];
	}
	GetMapping getMapping = context.findControllerAnnotation(GetMapping.class).orNull();
	if (getMapping != null) {
		return getMapping.name();
	}
	PostMapping postMapping = context.findControllerAnnotation(PostMapping.class).orNull();
	if (postMapping != null) {
		return postMapping.name();
	}
	DeleteMapping deleteMapping = context.findControllerAnnotation(DeleteMapping.class).orNull();
	if (deleteMapping != null) {
		return deleteMapping.name();
	}
	PutMapping putMapping = context.findControllerAnnotation(PutMapping.class).orNull();
	if (putMapping != null) {
		return putMapping.name();
	}
	RequestMapping requestMapping = context.findControllerAnnotation(RequestMapping.class).orNull();
	if (requestMapping != null) {
		return requestMapping.name();
	}
	return "";
}
 
Example 5
Source File: ApiProcessor.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
private void setTags(SwaggerGenerator swaggerGenerator, Api api) {
  String[] tags = api.tags();
  for (String tagName : tags) {
    if (StringUtils.isEmpty(tagName)) {
      continue;
    }
    swaggerGenerator.addDefaultTag(tagName);
  }
}
 
Example 6
Source File: SmartOperateLogAspect.java    From smart-admin with MIT License 4 votes vote down vote up
protected void handleLog(final JoinPoint joinPoint, final Exception e) {
    try {
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        OperateLog operateLog = this.getAnnotationLog(joinPoint);
        if (operateLog == null) {
            return;
        }
        RequestTokenBO requestToken = SmartRequestTokenUtil.getRequestUser();
        if (requestToken == null) {
            return;
        }
        // 设置方法名称
        String className = joinPoint.getTarget().getClass().getName();
        String methodName = joinPoint.getSignature().getName();
        String operateMethod = className + "." + methodName;
        Object[] args = joinPoint.getArgs();
        StringBuilder sb = new StringBuilder();
        for (Object obj : args) {
            sb.append(obj.getClass().getSimpleName());
            sb.append("[");
            sb.append(JSON.toJSONString(obj));
            sb.append("]");
        }
        String params = sb.toString();
        String failReason = null;
        Integer result = JudgeEnum.YES.getValue();
        if (e != null) {
            result = JudgeEnum.NO.getValue();
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw, true);
            e.printStackTrace(pw);
            failReason = sw.toString();
            pw.flush();
            pw.close();
            sw.flush();
            sw.close();
        }
        UserOperateLogEntity operateLogEntity =
            UserOperateLogEntity.builder().userId(requestToken.getRequestUserId()).userName(requestToken.getEmployeeBO().getActualName()).url(request.getRequestURI()).method(operateMethod).param(params).failReason(failReason).result(result).build();
        ApiOperation apiOperation = this.getApiOperation(joinPoint);
        if (apiOperation != null) {
            operateLogEntity.setContent(apiOperation.value());
        }
        Api api = this.getApi(joinPoint);
        if (api != null) {
            String[] tags = api.tags();
            operateLogEntity.setModule(SmartStringUtil.join(tags, ","));
        }
        logService.addLog(operateLogEntity);
    } catch (Exception exp) {
        log.error("保存操作日志异常:{}", exp.getMessage());
        exp.printStackTrace();
    }
}