use of io.apicurio.datamodels.openapi.v2.models.Oas20Example in project apicurio-data-models by Apicurio.
the class Oas20DataModelWriter method visitExample.
/**
* @see io.apicurio.datamodels.openapi.visitors.IOasVisitor#visitExample(io.apicurio.datamodels.core.models.common.IExample)
*/
@Override
public void visitExample(IExample node) {
Oas20Example example20 = (Oas20Example) node;
Object parent = this.lookupParentJson(example20);
Object json = JsonCompat.objectNode();
List<String> contentTypes = example20.getExampleContentTypes();
contentTypes.forEach(ct -> {
Object example = example20.getExample(ct);
JsonCompat.setProperty(json, ct, example);
});
JsonCompat.setProperty(parent, Constants.PROP_EXAMPLES, json);
this.updateIndex(example20, json);
}
use of io.apicurio.datamodels.openapi.v2.models.Oas20Example in project apicurio-data-models by Apicurio.
the class OasUnmatchedExampleTypeRule method visitExample.
/**
* @see io.apicurio.datamodels.combined.visitors.CombinedAllNodeVisitor#visitExample(io.apicurio.datamodels.core.models.common.IExample)
*/
@Override
public void visitExample(IExample node) {
Oas20Example example20 = (Oas20Example) node;
Oas20Document doc = (Oas20Document) example20.ownerDocument();
List<String> produces = doc.produces;
Oas20Operation operation = (Oas20Operation) findParentOperation(example20);
if (isDefined(operation)) {
if (hasValue(operation.produces)) {
produces = operation.produces;
}
if (!hasValue(produces)) {
produces = new ArrayList<>();
}
List<String> ctypes = example20.getExampleContentTypes();
for (String ct : ctypes) {
this.reportIfInvalid(produces.indexOf(ct) != -1, example20, Constants.PROP_PRODUCES, map("contentType", ct));
}
}
}
Aggregations