use of io.apicurio.datamodels.core.visitors.ConsumesProducesFinder in project apicurio-data-models by Apicurio.
the class Oas20to30TransformationVisitor method findConsumes.
private List<String> findConsumes(Node node) {
ConsumesProducesFinder finder = new ConsumesProducesFinder();
Library.visitTree(node, finder, TraverserDirection.up);
List<String> consumes = finder.consumes;
if (NodeCompat.isNullOrUndefined(consumes) || consumes.size() == 0) {
consumes = new ArrayList<>();
consumes.add("*/*");
}
return consumes;
}
use of io.apicurio.datamodels.core.visitors.ConsumesProducesFinder in project apicurio-data-models by Apicurio.
the class OasFormDataParamNotAllowedRule method visitParameter.
/**
* @see io.apicurio.datamodels.combined.visitors.CombinedAllNodeVisitor#visitParameter(io.apicurio.datamodels.core.models.common.Parameter)
*/
@Override
public void visitParameter(Parameter node) {
OasParameter param = (OasParameter) node;
if (equals(param.in, "formData")) {
ConsumesProducesFinder finder = new ConsumesProducesFinder();
VisitorUtil.visitTree(node, finder, TraverserDirection.up);
List<String> consumes = finder.consumes;
if (!hasValue(consumes)) {
consumes = new ArrayList<>();
}
boolean valid = consumes.indexOf("application/x-www-form-urlencoded") >= 0 || consumes.indexOf("multipart/form-data") >= 0;
this.reportIfInvalid(valid, node, Constants.PROP_CONSUMES, map());
}
}
use of io.apicurio.datamodels.core.visitors.ConsumesProducesFinder in project apicurio-data-models by Apicurio.
the class Oas20to30TransformationVisitor method findProduces.
private List<String> findProduces(Node node) {
ConsumesProducesFinder finder = new ConsumesProducesFinder();
Library.visitTree(node, finder, TraverserDirection.up);
List<String> produces = finder.produces;
if (NodeCompat.isNullOrUndefined(produces) || produces.size() == 0) {
produces = new ArrayList<>();
produces.add("*/*");
}
return produces;
}
Aggregations