Search in sources :

Example 1 with ConsumesProducesFinder

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;
}
Also used : ConsumesProducesFinder(io.apicurio.datamodels.core.visitors.ConsumesProducesFinder)

Example 2 with ConsumesProducesFinder

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());
    }
}
Also used : OasParameter(io.apicurio.datamodels.openapi.models.OasParameter) ConsumesProducesFinder(io.apicurio.datamodels.core.visitors.ConsumesProducesFinder)

Example 3 with ConsumesProducesFinder

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;
}
Also used : ConsumesProducesFinder(io.apicurio.datamodels.core.visitors.ConsumesProducesFinder)

Aggregations

ConsumesProducesFinder (io.apicurio.datamodels.core.visitors.ConsumesProducesFinder)3 OasParameter (io.apicurio.datamodels.openapi.models.OasParameter)1