com.zlyx.easy.swagger.plugins.EasySwaggerExpandedParameterBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of easy-swagger Show documentation
Show all versions of easy-swagger Show documentation
An useful tool for java developers when using swagger.
package com.zlyx.easy.swagger.plugins;
import java.util.Optional;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiParam;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spi.service.ExpandedParameterBuilderPlugin;
import springfox.documentation.spi.service.contexts.ParameterExpansionContext;
import springfox.documentation.swagger.common.SwaggerPluginSupport;
@Component
@Order(SwaggerPluginSupport.SWAGGER_PLUGIN_ORDER)
public class EasySwaggerExpandedParameterBuilder implements ExpandedParameterBuilderPlugin {
@Override
public void apply(ParameterExpansionContext context) {
Optional apiModelPropertyOptional = context.findAnnotation(ApiModelProperty.class);
Optional apiParamOptional = context.findAnnotation(ApiParam.class);
if (!apiModelPropertyOptional.isPresent() && !apiParamOptional.isPresent()) {
context.getParameterBuilder().description(context.getFieldName());
}
}
@Override
public boolean supports(DocumentationType delimiter) {
return SwaggerPluginSupport.pluginDoesApply(delimiter);
}
}