Java Code Examples for org.eclipse.microprofile.openapi.models.parameters.Parameter#getRef()

The following examples show how to use org.eclipse.microprofile.openapi.models.parameters.Parameter#getRef() . These examples are extracted from open source projects. 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
/**
 * 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 2
/**
 * 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;
}