Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

global-operation-parameters在不配置的情况下会出现空指针异常 #225

Open
eureka-lyq opened this issue Nov 29, 2021 · 6 comments

Comments

@eureka-lyq
Copy link

如题,在DocketConfiguration中创建createSpringFoxRestApi的时候,如果没有设置global-operation-parameters,下面的代码会报空指针
private List getRequestParameters(List<SwaggerProperties.GlobalOperationParameter> 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());
}

@eureka-lyq eureka-lyq changed the title global-operation-parameters并不配置的情况下会出现空指针异常 global-operation-parameters在不配置的情况下会出现空指针异常 Nov 29, 2021
@Yonsion
Copy link

Yonsion commented Dec 20, 2021

这个问题有什么方法规避掉吗?

@LSL1618
Copy link

LSL1618 commented Dec 23, 2021

配置一个空的swagger.globalOperationParameters[0]或者构建Docket的时候调用.globalOperationParameters(Collections.EMPTY_LIST)试试

@eureka-lyq
Copy link
Author

这个问题有什么方法规避掉吗?

在yml下可以设置个空的,如下:
swagger:
global-operation-parameters:
- name:
description:

但是还是建议官方修复

@silent-night-no-trace
Copy link

目前这个bug还在 建议修复下

@zijikanwa
Copy link

配置一个空的swagger.globalOperationParameters[0]或者构建Docket的时候调用.globalOperationParameters(Collections.EMPTY_LIST)试试

空的swagger.globalOperationParameters[0]该怎么配置,key和value在application文件中都需要填写,不然会报错

@LSL1618
Copy link

LSL1618 commented May 19, 2023

配置一个空的swagger.globalOperationParameters[0]或者构建Docket的时候调用.globalOperationParameters(Collections.EMPTY_LIST)试试

空的swagger.globalOperationParameters[0]该怎么配置,key和value在application文件中都需要填写,不然会报错

# 设置全局请求参数。
swagger.globalOperationParameters[0].name=argument
swagger.globalOperationParameters[0].description=参数
swagger.globalOperationParameters[0].type=string
swagger.globalOperationParameters[0].parameterType=form
swagger.globalOperationParameters[0].required=false
# 是否使用默认预定义的响应消息,并使用自定义响应消息
swagger.applyDefaultResponseMessages=true
swagger.globalResponseMessage.get[0].code=404
swagger.globalResponseMessage.get[0].description=请求未找到
swagger.globalResponseMessage.get[0].modelRef=ERROR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants