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

The following examples show how to use org.eclipse.microprofile.openapi.models.parameters.Parameter#setExample() . 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
/**
 * Reads a {@link Parameter} OpenAPI node.
 * 
 * @param node the json object
 * @return Parameter model
 */
public static Parameter readParameter(final JsonNode node) {
    if (node == null || !node.isObject()) {
        return null;
    }
    IoLogging.log.singleJsonObject("Parameter");
    Parameter parameter = new ParameterImpl();

    parameter.setName(JsonUtil.stringProperty(node, Parameterizable.PROP_NAME));
    parameter.setIn(readParameterIn(node.get(ParameterConstant.PROP_IN)));
    parameter.setDescription(JsonUtil.stringProperty(node, Parameterizable.PROP_DESCRIPTION));
    parameter.setRequired(JsonUtil.booleanProperty(node, Parameterizable.PROP_REQUIRED).orElse(null));
    parameter.setDeprecated(JsonUtil.booleanProperty(node, Parameterizable.PROP_DEPRECATED).orElse(null));
    parameter.setAllowEmptyValue(JsonUtil.booleanProperty(node, Parameterizable.PROP_ALLOW_EMPTY_VALUE).orElse(null));
    parameter.setStyle(readParameterStyle(node.get(Parameterizable.PROP_STYLE)));
    parameter.setExplode(JsonUtil.booleanProperty(node, Parameterizable.PROP_EXPLODE).orElse(null));
    parameter.setAllowReserved(JsonUtil.booleanProperty(node, ParameterConstant.PROP_ALLOW_RESERVED).orElse(null));
    parameter.setSchema(SchemaReader.readSchema(node.get(Parameterizable.PROP_SCHEMA)));
    parameter.setContent(ContentReader.readContent(node.get(Parameterizable.PROP_CONTENT)));
    parameter.setExamples(ExampleReader.readExamples(node.get(Parameterizable.PROP_EXAMPLES)));
    parameter.setExample(readObject(node.get(Parameterizable.PROP_EXAMPLE)));
    parameter.setRef(JsonUtil.stringProperty(node, Referenceable.PROP_$REF));
    ExtensionReader.readExtensions(node, parameter);

    return parameter;
}
 
Example 2
/**
 * Reads a Parameter annotation into a model.
 * 
 * @param context the scanning context
 * @param annotationInstance {@literal @}Parameter model
 * @return Parameter model
 */
public static Parameter readParameter(final AnnotationScannerContext context,
        final AnnotationInstance annotationInstance) {

    if (annotationInstance == null) {
        return null;
    }
    IoLogging.log.singleAnnotation("@Parameter");
    Parameter parameter = new ParameterImpl();
    parameter.setName(JandexUtil.stringValue(annotationInstance, Parameterizable.PROP_NAME));
    parameter.setIn(JandexUtil.enumValue(annotationInstance, ParameterConstant.PROP_IN,
            org.eclipse.microprofile.openapi.models.parameters.Parameter.In.class));

    // Params can be hidden. Skip if that's the case.
    Optional<Boolean> isHidden = JandexUtil.booleanValue(annotationInstance, ParameterConstant.PROP_HIDDEN);
    if (isHidden.isPresent() && isHidden.get()) {
        ParameterImpl.setHidden(parameter, true);
        return parameter;
    }

    parameter.setDescription(JandexUtil.stringValue(annotationInstance, Parameterizable.PROP_DESCRIPTION));
    parameter.setRequired(JandexUtil.booleanValue(annotationInstance, Parameterizable.PROP_REQUIRED).orElse(null));
    parameter.setDeprecated(JandexUtil.booleanValue(annotationInstance, Parameterizable.PROP_DEPRECATED).orElse(null));
    parameter.setAllowEmptyValue(
            JandexUtil.booleanValue(annotationInstance, Parameterizable.PROP_ALLOW_EMPTY_VALUE).orElse(null));
    parameter.setStyle(JandexUtil.enumValue(annotationInstance, Parameterizable.PROP_STYLE,
            org.eclipse.microprofile.openapi.models.parameters.Parameter.Style.class));
    parameter.setExplode(readExplode(JandexUtil.enumValue(annotationInstance, Parameterizable.PROP_EXPLODE,
            org.eclipse.microprofile.openapi.annotations.enums.Explode.class)).orElse(null));
    parameter.setAllowReserved(
            JandexUtil.booleanValue(annotationInstance, ParameterConstant.PROP_ALLOW_RESERVED).orElse(null));
    parameter.setSchema(
            SchemaFactory.readSchema(context.getIndex(),
                    annotationInstance.value(Parameterizable.PROP_SCHEMA)));
    parameter.setContent(
            ContentReader.readContent(context, annotationInstance.value(Parameterizable.PROP_CONTENT),
                    ContentDirection.PARAMETER));
    parameter.setExamples(ExampleReader.readExamples(annotationInstance.value(Parameterizable.PROP_EXAMPLES)));
    parameter.setExample(JandexUtil.stringValue(annotationInstance, Parameterizable.PROP_EXAMPLE));
    parameter.setRef(JandexUtil.refValue(annotationInstance, JandexUtil.RefType.Parameter));
    return parameter;
}