All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.zlyx.easy.swagger.plugins.EasySwaggerExpandedParameterBuilder Maven / Gradle / Ivy

There is a newer version: 4.3.11
Show newest version
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);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy