Search in sources :

Example 1 with ExampleImpl

use of org.wildfly.swarm.microprofile.openapi.api.models.examples.ExampleImpl in project wildfly-swarm by wildfly-swarm.

the class OpenApiParser method readExample.

/**
 * Reads a {@link Example} OpenAPI node.
 * @param node
 */
private Example readExample(JsonNode node) {
    if (node == null || !node.isObject()) {
        return null;
    }
    ExampleImpl model = new ExampleImpl();
    model.setRef(JsonUtil.stringProperty(node, OpenApiConstants.PROP_$REF));
    model.setSummary(JsonUtil.stringProperty(node, OpenApiConstants.PROP_SUMMARY));
    model.setDescription(JsonUtil.stringProperty(node, OpenApiConstants.PROP_DESCRIPTION));
    model.setValue(readObject(node.get(OpenApiConstants.PROP_VALUE)));
    model.setExternalValue(JsonUtil.stringProperty(node, OpenApiConstants.PROP_EXTERNAL_VALUE));
    readExtensions(node, model);
    return model;
}
Also used : ExampleImpl(org.wildfly.swarm.microprofile.openapi.api.models.examples.ExampleImpl)

Example 2 with ExampleImpl

use of org.wildfly.swarm.microprofile.openapi.api.models.examples.ExampleImpl in project wildfly-swarm by wildfly-swarm.

the class OpenApiAnnotationScanner method readExample.

/**
 * Reads a Example annotation into a model.
 * @param annotation
 */
private Example readExample(AnnotationInstance annotation) {
    if (annotation == null) {
        return null;
    }
    LOG.debug("Processing a single @ExampleObject annotation.");
    Example example = new ExampleImpl();
    example.setSummary(JandexUtil.stringValue(annotation, OpenApiConstants.PROP_SUMMARY));
    example.setDescription(JandexUtil.stringValue(annotation, OpenApiConstants.PROP_DESCRIPTION));
    example.setValue(JandexUtil.stringValue(annotation, OpenApiConstants.PROP_VALUE));
    example.setExternalValue(JandexUtil.stringValue(annotation, OpenApiConstants.PROP_EXTERNAL_VALUE));
    example.setRef(JandexUtil.refValue(annotation, RefType.Example));
    return example;
}
Also used : Example(org.eclipse.microprofile.openapi.models.examples.Example) ExampleImpl(org.wildfly.swarm.microprofile.openapi.api.models.examples.ExampleImpl)

Aggregations

ExampleImpl (org.wildfly.swarm.microprofile.openapi.api.models.examples.ExampleImpl)2 Example (org.eclipse.microprofile.openapi.models.examples.Example)1