Java Code Examples for springfox.documentation.builders.ParameterBuilder#description()

The following examples show how to use springfox.documentation.builders.ParameterBuilder#description() . 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: DefaultParamPlugin.java    From BlogManagePlatform with Apache License 2.0 6 votes vote down vote up
private void resolveApiParam(ParameterContext context) {
	ResolvedType resolvedType = context.resolvedMethodParameter().getParameterType();
	Class<?> parameterClass = resolveParamType(resolvedType);
	if (parameterClass == null) {
		log.warn(StrUtil.concat(resolvedType.getBriefDescription(), "的类型无法被DefaultParamPlugin解析"));
		@SuppressWarnings("unused") int a = 1;
		return;
	}
	ApiModel apiModel = parameterClass.getAnnotation(ApiModel.class);
	if (apiModel == null) {
		if (!BeanUtils.isSimpleProperty(parameterClass)) {
			warn(context, parameterClass);
		}
		return;
	}
	ParameterBuilder builder = context.parameterBuilder();
	builder.name(apiModel.description());
	builder.description(descriptions.resolve(apiModel.description()));
	builder.allowMultiple(false);
	builder.allowEmptyValue(false);
	builder.hidden(false);
	builder.collectionFormat("");
	builder.order(SWAGGER_PLUGIN_ORDER);
}
 
Example 2
Source File: DefaultTokenPlugin.java    From BlogManagePlatform with Apache License 2.0 5 votes vote down vote up
private Parameter addTokenHeader() {
	String description = StrUtil.concat("token前缀:\n", securityProperties.getJwt().getTokenPrefix());
	ParameterBuilder builder = new ParameterBuilder();
	builder.name(securityProperties.getJwt().getHeader());
	builder.description(description);
	builder.required(true);
	builder.parameterType("header");
	builder.modelRef(new ModelRef("string"));
	return builder.build();
}
 
Example 3
Source File: DefaultParamPlugin.java    From BlogManagePlatform with Apache License 2.0 5 votes vote down vote up
@SneakyThrows
private void resolveMapEnum(ParameterContext context) {
	MapEnum enumParam = context.resolvedMethodParameter().findAnnotation(MapEnum.class).orNull();
	if (enumParam != null) {
		String descs = MapEnumHelper.getDescs(enumParam.value(), enumParam.descMethod());
		Object defaultValue = MapEnumHelper.getDefaultValue(enumParam.value());
		ParameterBuilder builder = context.parameterBuilder();
		builder.description(descs);
		builder.scalarExample(new Example(defaultValue == null ? DefStr.EMPTY : defaultValue.toString()));
		builder.allowableValues(MapEnumHelper.getAllowableValues(enumParam.value()));
		builder.defaultValue(defaultValue == null ? DefStr.EMPTY : defaultValue.toString());
	}
}