Java Code Examples for org.springframework.web.bind.annotation.RequestHeader#required()
The following examples show how to use
org.springframework.web.bind.annotation.RequestHeader#required() .
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: AbstractRequestBuilder.java From springdoc-openapi with Apache License 2.0 | 5 votes |
/** * Build params parameter. * * @param parameterInfo the parameter info * @param components the components * @param requestMethod the request method * @param jsonView the json view * @return the parameter */ public Parameter buildParams(ParameterInfo parameterInfo, Components components, RequestMethod requestMethod, JsonView jsonView) { MethodParameter methodParameter = parameterInfo.getMethodParameter(); RequestHeader requestHeader = parameterInfo.getRequestHeader(); RequestParam requestParam = parameterInfo.getRequestParam(); PathVariable pathVar = parameterInfo.getPathVar(); CookieValue cookieValue = parameterInfo.getCookieValue(); RequestInfo requestInfo; if (requestHeader != null) { requestInfo = new RequestInfo(ParameterIn.HEADER.toString(), parameterInfo.getpName(), requestHeader.required(), requestHeader.defaultValue()); return buildParam(parameterInfo, components, requestInfo, jsonView); } else if (requestParam != null && !parameterBuilder.isFile(parameterInfo.getMethodParameter())) { requestInfo = new RequestInfo(ParameterIn.QUERY.toString(), parameterInfo.getpName(), requestParam.required() && !methodParameter.isOptional(), requestParam.defaultValue()); return buildParam(parameterInfo, components, requestInfo, jsonView); } else if (pathVar != null) { requestInfo = new RequestInfo(ParameterIn.PATH.toString(), parameterInfo.getpName(), !methodParameter.isOptional(), null); return buildParam(parameterInfo, components, requestInfo, jsonView); } else if (cookieValue != null) { requestInfo = new RequestInfo(ParameterIn.COOKIE.toString(), parameterInfo.getpName(), cookieValue.required(), cookieValue.defaultValue()); return buildParam(parameterInfo, components, requestInfo, jsonView); } // By default DelegatingMethodParameter delegatingMethodParameter = (DelegatingMethodParameter) methodParameter; if (RequestMethod.GET.equals(requestMethod) || (parameterInfo.getParameterModel() != null && (ParameterIn.PATH.toString().equals(parameterInfo.getParameterModel().getIn()))) || delegatingMethodParameter.isParameterObject()) return this.buildParam(QUERY_PARAM, components, parameterInfo, !methodParameter.isOptional(), null, jsonView); return null; }
Example 2
Source File: RequestHeaderSnippet.java From spring-auto-restdocs with Apache License 2.0 | 5 votes |
@Override protected boolean isRequired(MethodParameter param, RequestHeader annot) { // Spring disallows null for primitive types // For types wrapped in Optional or nullable Kotlin types, the required flag in // the annotation is ignored by Spring. return param.getParameterType().isPrimitive() || (!param.isOptional() && annot.required()); }
Example 3
Source File: RequestHeaderMethodArgumentResolver.java From spring-analysis-note with MIT License | 4 votes |
private RequestHeaderNamedValueInfo(RequestHeader annotation) { super(annotation.name(), annotation.required(), annotation.defaultValue()); }
Example 4
Source File: RequestHeaderMethodArgumentResolver.java From spring-analysis-note with MIT License | 4 votes |
private RequestHeaderNamedValueInfo(RequestHeader annotation) { super(annotation.name(), annotation.required(), annotation.defaultValue()); }
Example 5
Source File: RequestHeaderMethodArgumentResolver.java From java-technology-stack with MIT License | 4 votes |
private RequestHeaderNamedValueInfo(RequestHeader annotation) { super(annotation.name(), annotation.required(), annotation.defaultValue()); }
Example 6
Source File: RequestHeaderMethodArgumentResolver.java From java-technology-stack with MIT License | 4 votes |
private RequestHeaderNamedValueInfo(RequestHeader annotation) { super(annotation.name(), annotation.required(), annotation.defaultValue()); }
Example 7
Source File: RequestHeaderAnnotationProcessor.java From servicecomb-java-chassis with Apache License 2.0 | 4 votes |
@Override protected boolean readRequired(RequestHeader requestHeader) { return requestHeader.required(); }
Example 8
Source File: RequestHeaderMethodArgumentResolver.java From lams with GNU General Public License v2.0 | 4 votes |
private RequestHeaderNamedValueInfo(RequestHeader annotation) { super(annotation.name(), annotation.required(), annotation.defaultValue()); }
Example 9
Source File: RequestHeaderMethodArgumentResolver.java From spring4-understanding with Apache License 2.0 | 4 votes |
private RequestHeaderNamedValueInfo(RequestHeader annotation) { super(annotation.name(), annotation.required(), annotation.defaultValue()); }