spring-boot-starter-swagger
spring-boot-starter-swagger copied to clipboard
自制spring boot starter for swagger 2.x,来试试吧,很好用哦~
   是我什么地方没有配置对吗?
通过界面请求时,经常需要去填一些固定的值,希望能设置默认值
globalOperationParameter不能设置默认值
 我配置了 server: servlet: context-path: /api 如果在swagger所有请求前添加/api前缀
如题,在DocketConfiguration中创建createSpringFoxRestApi的时候,如果没有设置global-operation-parameters,下面的代码会报空指针 private List getRequestParameters(List properties) { return properties.stream() .map(param -> new RequestParameterBuilder().name(param.getName()).description(param.getDescription()) .in(ParameterType.from(param.getParameterType())).required(param.getRequired()) .query(q -> q.defaultValue(param.getType())) .query(q -> q.model(m -> m.scalarModel(!ScalarType.from(param.getType(), param.getFormat()).isPresent() ? ScalarType.STRING : ScalarType.from(param.getType(), param.getFormat()).get()))) .build()) .collect(Collectors.toList()); }
o.s.c.a.ConfigurationClassEnhancer : @Bean method SwaggerAutoConfiguration.docketBeanFactoryPostProcessor is non-static and returns an object assignable to Spring's BeanFactoryPostProcessor interface. This will result in a failure to process annotations such as @Autowired, @Resource and...
```java public class SwaggerProperties{ private List globalOperationParameters; } public class DocketConfiguration implements BeanFactoryAware{ docket4Group.host(this.swaggerProperties.getHost()).apiInfo(apiInfo).globalRequestParameters(this.assemblyRequestParameters(this.swaggerProperties.getGlobalOperationParameters(), new ArrayList())).securityContexts(Collections.singletonList(this.authConfiguration.securityContext())).securitySchemes(this.authConfiguration.getSecuritySchemes()).select().apis(RequestHandlerSelectors.basePackage(this.swaggerProperties.getBasePackage())).paths(this.paths(this.swaggerProperties.getBasePath(), this.swaggerProperties.getExcludePath())).build(); } //第74行 public void createSpringFoxRestApi(){} ``` 如项目中未配置 ```yarm swagger.globalOperationParameters[0].name=name one swagger.globalOperationParameters[0].description=some description one...
目前(2.0.0版本)对单个Docket已经实现大部分之前版本的配置功能,但对于多docket的配置还未实现。 该功能说明可见:https://github.com/SpringForAll/spring-boot-starter-swagger#%E5%88%86%E7%BB%84%E9%85%8D%E7%BD%AE 具体配置样例如下; ``` - swagger.docket..title=标题 - swagger.docket..description=描述 - swagger.docket..version=版本 - swagger.docket..license=许可证 - swagger.docket..licenseUrl=许可证URL - swagger.docket..termsOfServiceUrl=服务条款URL - swagger.docket..contact.name=维护人 - swagger.docket..contact.url=维护人URL - swagger.docket..contact.email=维护人email - swagger.docket..base-package=swagger扫描的基础包,默认:全扫描 - swagger.docket..base-path=需要处理的基础URL规则,默认:/** - swagger.docket..exclude-path=需要排除的URL规则,默认:空 - swagger.docket..name=参数名...