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);
}
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;
}
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);
}
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);
}
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;
}
Aggregations