Search in sources :

Example 1 with Oas20Parameter

use of io.apicurio.datamodels.openapi.v2.models.Oas20Parameter in project apicurio-data-models by Apicurio.

the class NewRequestBodyCommand_20 method doCreateRequestBody.

/**
 * @see io.apicurio.datamodels.cmd.commands.NewRequestBodyCommand#doCreateRequestBody(io.apicurio.datamodels.openapi.models.OasOperation)
 */
@Override
protected void doCreateRequestBody(OasOperation operation) {
    if (this.isNullOrUndefined(operation.parameters)) {
        operation.parameters = new ArrayList<>();
    }
    Oas20Parameter param = (Oas20Parameter) operation.createParameter();
    param.in = "body";
    param.name = "body";
    operation.addParameter(param);
}
Also used : Oas20Parameter(io.apicurio.datamodels.openapi.v2.models.Oas20Parameter)

Example 2 with Oas20Parameter

use of io.apicurio.datamodels.openapi.v2.models.Oas20Parameter in project apicurio-data-models by Apicurio.

the class ChangeParameterTypeCommand_20 method doRestoreParameter.

/**
 * @see io.apicurio.datamodels.cmd.commands.ChangeParameterTypeCommand#doRestoreParameter(io.apicurio.datamodels.core.models.common.Parameter, io.apicurio.datamodels.core.models.common.Parameter)
 */
@Override
protected void doRestoreParameter(Parameter parameter, Parameter oldParameter) {
    Oas20Parameter param = (Oas20Parameter) parameter;
    Oas20Parameter oldParam = (Oas20Parameter) oldParameter;
    if (NodeCompat.equals(param.in, "body")) {
        param.schema = oldParam.schema;
        if (ModelUtils.isDefined(param.schema)) {
            param.schema._parent = param;
            param.schema._ownerDocument = param.ownerDocument();
        }
    } else {
        param.type = oldParam.type;
        param.format = oldParam.format;
        param.items = oldParam.items;
        if (ModelUtils.isDefined(param.items)) {
            param.items._parent = param;
            param.items._ownerDocument = param.ownerDocument();
        }
    }
    param.required = oldParam.required;
}
Also used : Oas20Parameter(io.apicurio.datamodels.openapi.v2.models.Oas20Parameter)

Example 3 with Oas20Parameter

use of io.apicurio.datamodels.openapi.v2.models.Oas20Parameter in project apicurio-data-models by Apicurio.

the class Oas20Traverser method traverseParameter.

/**
 * @see io.apicurio.datamodels.core.visitors.Traverser#traverseParameter(io.apicurio.datamodels.core.models.common.Parameter)
 */
@Override
protected void traverseParameter(Parameter node) {
    super.traverseParameter(node);
    Oas20Parameter param = (Oas20Parameter) node;
    this.traverseIfNotNull(param.items);
}
Also used : Oas20Parameter(io.apicurio.datamodels.openapi.v2.models.Oas20Parameter)

Example 4 with Oas20Parameter

use of io.apicurio.datamodels.openapi.v2.models.Oas20Parameter in project apicurio-data-models by Apicurio.

the class Oas20DataModelReader method readParameter.

/**
 * @see io.apicurio.datamodels.openapi.io.OasDataModelReader#readParameter(java.lang.Object, io.apicurio.datamodels.core.models.common.Parameter)
 */
@Override
public void readParameter(Object json, Parameter node) {
    Oas20Parameter param = (Oas20Parameter) node;
    String type = JsonCompat.consumePropertyString(json, Constants.PROP_TYPE);
    String format = JsonCompat.consumePropertyString(json, Constants.PROP_FORMAT);
    Object items = JsonCompat.consumeProperty(json, Constants.PROP_ITEMS);
    String collectionFormat = JsonCompat.consumePropertyString(json, Constants.PROP_COLLECTION_FORMAT);
    Object default_ = JsonCompat.consumePropertyObject(json, Constants.PROP_DEFAULT);
    Number maximum = JsonCompat.consumePropertyNumber(json, Constants.PROP_MAXIMUM);
    Boolean exclusiveMaximum = JsonCompat.consumePropertyBoolean(json, Constants.PROP_EXCLUSIVE_MAXIMUM);
    Number minimum = JsonCompat.consumePropertyNumber(json, Constants.PROP_MINIMUM);
    Boolean exclusiveMinimum = JsonCompat.consumePropertyBoolean(json, Constants.PROP_EXCLUSIVE_MINIMUM);
    Number maxLength = JsonCompat.consumePropertyNumber(json, Constants.PROP_MAX_LENGTH);
    Number minLength = JsonCompat.consumePropertyNumber(json, Constants.PROP_MIN_LENGTH);
    String pattern = JsonCompat.consumePropertyString(json, Constants.PROP_PATTERN);
    Number maxItems = JsonCompat.consumePropertyNumber(json, Constants.PROP_MAX_ITEMS);
    Number minItems = JsonCompat.consumePropertyNumber(json, Constants.PROP_MIN_ITEMS);
    Boolean uniqueItems = JsonCompat.consumePropertyBoolean(json, Constants.PROP_UNIQUE_ITEMS);
    List<String> enum_ = JsonCompat.consumePropertyStringArray(json, Constants.PROP_ENUM);
    Number multipleOf = JsonCompat.consumePropertyNumber(json, Constants.PROP_MULTIPLE_OF);
    param.type = type;
    param.format = format;
    param.collectionFormat = collectionFormat;
    param.default_ = default_;
    param.maximum = maximum;
    param.exclusiveMaximum = exclusiveMaximum;
    param.minimum = minimum;
    param.exclusiveMinimum = exclusiveMinimum;
    param.maxLength = maxLength;
    param.minLength = minLength;
    param.pattern = pattern;
    param.maxItems = maxItems;
    param.minItems = minItems;
    param.uniqueItems = uniqueItems;
    param.enum_ = enum_;
    param.multipleOf = multipleOf;
    if (items != null) {
        param.items = param.createItems();
        this.readItems(items, param.items);
    }
    super.readParameter(json, node);
}
Also used : Oas20Parameter(io.apicurio.datamodels.openapi.v2.models.Oas20Parameter)

Example 5 with Oas20Parameter

use of io.apicurio.datamodels.openapi.v2.models.Oas20Parameter in project apicurio-data-models by Apicurio.

the class SimplifiedParameterType method fromParameter.

public static SimplifiedParameterType fromParameter(Parameter param) {
    SimplifiedParameterType rval = new SimplifiedParameterType();
    SimplifiedType st;
    if (param.ownerDocument().getDocumentType() == DocumentType.openapi2) {
        Oas20Parameter param20 = (Oas20Parameter) param;
        if (NodeCompat.equals(param20.in, "body")) {
            st = SimplifiedType.fromSchema((OasSchema) param20.schema);
        } else {
            st = SimplifiedType.fromParameter((Oas20Parameter) param);
        }
        rval.required = param20.required;
    } else {
        Oas30Parameter param30 = (Oas30Parameter) param;
        st = SimplifiedType.fromSchema((OasSchema) param30.schema);
        rval.required = param30.required;
    }
    rval.type = st.type;
    rval.enum_ = st.enum_;
    rval.of = st.of;
    rval.as = st.as;
    return rval;
}
Also used : OasSchema(io.apicurio.datamodels.openapi.models.OasSchema) Oas30Parameter(io.apicurio.datamodels.openapi.v3.models.Oas30Parameter) Oas20Parameter(io.apicurio.datamodels.openapi.v2.models.Oas20Parameter)

Aggregations

Oas20Parameter (io.apicurio.datamodels.openapi.v2.models.Oas20Parameter)26 Oas20Document (io.apicurio.datamodels.openapi.v2.models.Oas20Document)14 Test (org.junit.Test)12 Oas20Operation (io.apicurio.datamodels.openapi.v2.models.Oas20Operation)11 Oas20PathItem (io.apicurio.datamodels.openapi.v2.models.Oas20PathItem)10 Oas20Schema (io.apicurio.datamodels.openapi.v2.models.Oas20Schema)10 Oas20SchemaDefinition (io.apicurio.datamodels.openapi.v2.models.Oas20SchemaDefinition)8 Oas20Items (io.apicurio.datamodels.openapi.v2.models.Oas20Items)4 Oas20Response (io.apicurio.datamodels.openapi.v2.models.Oas20Response)4 OpenApiModelInfo (io.syndesis.server.api.generator.openapi.OpenApiModelInfo)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 Oas20ParameterDefinition (io.apicurio.datamodels.openapi.v2.models.Oas20ParameterDefinition)2 Oas30Schema (io.apicurio.datamodels.openapi.v3.models.Oas30Schema)2 ArrayList (java.util.ArrayList)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 Library (io.apicurio.datamodels.Library)1 JsonCompat (io.apicurio.datamodels.compat.JsonCompat)1 NodeCompat (io.apicurio.datamodels.compat.NodeCompat)1 Constants (io.apicurio.datamodels.core.Constants)1 Document (io.apicurio.datamodels.core.models.Document)1