Java Code Examples for org.eclipse.microprofile.openapi.models.parameters.Parameter#getIn()
The following examples show how to use
org.eclipse.microprofile.openapi.models.parameters.Parameter#getIn() .
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: ParameterProcessor.java From smallrye-open-api with Apache License 2.0 | 6 votes |
/** * Retrieves either the provided parameter {@link Parameter.Style}, the default * style of the parameter based on the <code>in</code> attribute, or null if <code>in</code> is not defined. * * @param param the {@link Parameter} * @return the param's style, the default style defined based on <code>in</code>, or null if <code>in</code> is not defined. */ Style styleOf(Parameter param) { if (param.getStyle() != null) { return param.getStyle(); } if (param.getIn() != null) { switch (param.getIn()) { case COOKIE: case QUERY: return Style.FORM; case HEADER: case PATH: return Style.SIMPLE; default: break; } } return null; }
Example 2
Source File: ParameterProcessor.java From smallrye-open-api with Apache License 2.0 | 6 votes |
/** * Retrieves either the provided parameter {@link Parameter.Style}, the default * style of the parameter based on the <code>in</code> attribute, or null if <code>in</code> is not defined. * * @param param the {@link Parameter} * @return the param's style, the default style defined based on <code>in</code>, or null if <code>in</code> is not defined. */ Style styleOf(Parameter param) { if (param.getStyle() != null) { return param.getStyle(); } if (param.getIn() != null) { switch (param.getIn()) { case COOKIE: case QUERY: return Style.FORM; case HEADER: case PATH: return Style.SIMPLE; default: break; } } return null; }
Example 3
Source File: MergeUtil.java From smallrye-open-api with Apache License 2.0 | 6 votes |
/** * Merge two lists of Parameters. Parameters are a special case because they must be unique * by the name in 'in' each have * * @param values1 * @param values2 */ private static List<Parameter> mergeParameterLists(List<Parameter> values1, List<Parameter> values2) { values1 = new ArrayList<>(values1); for (Parameter value2 : values2) { Parameter match = null; for (Parameter value1 : values1) { if (value1.getName() == null || !value1.getName().equals(value2.getName())) { continue; } if (value1.getIn() == null || !value1.getIn().equals(value2.getIn())) { continue; } match = value1; break; } if (match == null) { values1.add(value2); } else { mergeObjects(match, value2); } } return values1; }
Example 4
Source File: ParameterProcessor.java From smallrye-open-api with Apache License 2.0 | 4 votes |
/** * Determine if this is an ignored parameter, per the MP+OAI specification in * {@link org.eclipse.microprofile.openapi.annotations.parameters.Parameter @Parameter}. * * Path parameters that do not have a corresponding path segment will be ignored. * * @param parameter * the parameter to determine if ignored * @param resourceMethod * the resource method to which the parameter may apply * @return true if the parameter should be ignored, false otherwise * * @see org.eclipse.microprofile.openapi.annotations.parameters.Parameter#name() * @see org.eclipse.microprofile.openapi.annotations.parameters.Parameter#in() */ static boolean isIgnoredParameter(Parameter parameter, AnnotationTarget resourceMethod) { String paramName = parameter.getName(); In paramIn = parameter.getIn(); if (paramIn == null) { /* * Per @Parameter JavaDoc, ignored when empty string (i.e., unspecified). * This may occur when @Parameter is specified without a matching JAX-RS * parameter annotation. */ return true; } if (ParameterImpl.isHidden(parameter)) { return true; } /* * Name is REQUIRED unless it is a reference. */ if ((paramName == null || paramName.trim().isEmpty()) && parameter.getRef() == null) { return true; } if (paramIn == In.PATH && !parameterInPath(paramName, parameter.getStyle(), fullPathOf(resourceMethod))) { return true; } if (paramIn == Parameter.In.HEADER && paramName != null) { switch (paramName.toUpperCase()) { case "ACCEPT": case "AUTHORIZATION": case "CONTENT-TYPE": return true; default: break; } } return false; }
Example 5
Source File: ParameterProcessor.java From smallrye-open-api with Apache License 2.0 | 4 votes |
/** * Determine if this is an ignored parameter, per the MP+OAI specification in * {@link org.eclipse.microprofile.openapi.annotations.parameters.Parameter @Parameter}. * * Path parameters that do not have a corresponding path segment will be ignored. * * @param parameter * the parameter to determine if ignored * @param resourceMethod * the resource method to which the parameter may apply * @return true if the parameter should be ignored, false otherwise * * @see org.eclipse.microprofile.openapi.annotations.parameters.Parameter#name() * @see org.eclipse.microprofile.openapi.annotations.parameters.Parameter#in() */ static boolean isIgnoredParameter(Parameter parameter, AnnotationTarget resourceMethod) { String paramName = parameter.getName(); In paramIn = parameter.getIn(); if (paramIn == null) { /* * Per @Parameter JavaDoc, ignored when empty string (i.e., unspecified). * This may occur when @Parameter is specified without a matching Spring * parameter annotation. */ return true; } if (ParameterImpl.isHidden(parameter)) { return true; } /* * Name is REQUIRED unless it is a reference. */ if ((paramName == null || paramName.trim().isEmpty()) && parameter.getRef() == null) { return true; } if (paramIn == In.PATH && !parameterInPath(paramName, parameter.getStyle(), fullPathOf(resourceMethod))) { return true; } if (paramIn == Parameter.In.HEADER && paramName != null) { switch (paramName.toUpperCase()) { case "ACCEPT": case "AUTHORIZATION": case "CONTENT-TYPE": return true; default: break; } } return false; }