use of io.apicurio.datamodels.openapi.v3.models.Oas30Schema in project apicurio-data-models by Apicurio.
the class AbstractSchemaInhCommand method copySchemaJsTo.
/**
* Copies the given list of schemas to the appropriate property on the model
* @param schemas
* @param targetSchema
* @param inheritanceType
*/
protected void copySchemaJsTo(List<Object> schemas, OasSchema targetSchema, String inheritanceType) {
if (NodeCompat.equals(TYPE_ALL_OF, inheritanceType)) {
schemas.forEach(ser -> {
targetSchema.addAllOfSchema((OasSchema) Library.readNode(ser, targetSchema.createAllOfSchema()));
});
}
if (NodeCompat.equals(TYPE_ANY_OF, inheritanceType)) {
Oas30Schema targetSchema30 = (Oas30Schema) targetSchema;
schemas.forEach(ser -> {
targetSchema30.addAnyOfSchema((Oas30AnyOfSchema) Library.readNode(ser, targetSchema30.createAnyOfSchema()));
});
}
if (NodeCompat.equals(TYPE_ONE_OF, inheritanceType)) {
Oas30Schema targetSchema30 = (Oas30Schema) targetSchema;
schemas.forEach(ser -> {
targetSchema30.addOneOfSchema((Oas30OneOfSchema) Library.readNode(ser, targetSchema30.createOneOfSchema()));
});
}
}
use of io.apicurio.datamodels.openapi.v3.models.Oas30Schema in project apicurio-data-models by Apicurio.
the class Oas30DataModelReader method readSchema.
/**
* @see io.apicurio.datamodels.openapi.io.OasDataModelReader#readSchema(java.lang.Object, io.apicurio.datamodels.core.models.common.Schema)
*/
@Override
public void readSchema(Object json, Schema node) {
Oas30Schema schema = (Oas30Schema) node;
List<Object> oneOf = JsonCompat.consumePropertyArray(json, Constants.PROP_ONE_OF);
List<Object> anyOf = JsonCompat.consumePropertyArray(json, Constants.PROP_ANY_OF);
Object not = JsonCompat.consumeProperty(json, Constants.PROP_NOT);
Object discriminator = JsonCompat.consumeProperty(json, Constants.PROP_DISCRIMINATOR);
Boolean nullable = JsonCompat.consumePropertyBoolean(json, Constants.PROP_NULLABLE);
Boolean writeOnly = JsonCompat.consumePropertyBoolean(json, Constants.PROP_WRITE_ONLY);
Boolean deprecated = JsonCompat.consumePropertyBoolean(json, Constants.PROP_DEPRECATED);
schema.nullable = nullable;
schema.writeOnly = writeOnly;
schema.deprecated = deprecated;
if (oneOf != null) {
oneOf.forEach(oneOfSchema -> {
Oas30OneOfSchema oneOfSchemaModel = schema.createOneOfSchema();
this.readSchema(oneOfSchema, oneOfSchemaModel);
schema.addOneOfSchema(oneOfSchemaModel);
});
}
if (anyOf != null) {
anyOf.forEach(anyOfSchema -> {
Oas30AnyOfSchema anyOfSchemaModel = schema.createAnyOfSchema();
this.readSchema(anyOfSchema, anyOfSchemaModel);
schema.addAnyOfSchema(anyOfSchemaModel);
});
}
if (not != null) {
schema.not = schema.createNotSchema();
this.readSchema(not, schema.not);
}
if (discriminator != null) {
schema.discriminator = schema.createDiscriminator();
this.readDiscriminator(discriminator, schema.discriminator);
}
super.readSchema(json, node);
}
use of io.apicurio.datamodels.openapi.v3.models.Oas30Schema in project apicurio-data-models by Apicurio.
the class Oas30Traverser method traverseSchema.
/**
* @see io.apicurio.datamodels.openapi.visitors.OasTraverser#traverseSchema(io.apicurio.datamodels.core.models.common.Schema)
*/
@Override
protected void traverseSchema(Schema node) {
super.traverseSchema(node);
Oas30Schema schema = (Oas30Schema) node;
this.traverseCollection(schema.oneOf);
this.traverseCollection(schema.anyOf);
this.traverseIfNotNull(schema.not);
this.traverseIfNotNull(schema.discriminator);
}
use of io.apicurio.datamodels.openapi.v3.models.Oas30Schema in project apicurio-data-models by Apicurio.
the class Oas20to30TransformationVisitor method visitItemsSchema.
/**
* @see io.apicurio.datamodels.openapi.visitors.IOasVisitor#visitItemsSchema(io.apicurio.datamodels.openapi.models.OasSchema)
*/
@Override
public void visitItemsSchema(OasSchema node) {
Oas30Schema parent30 = (Oas30Schema) this.lookup(node.parent());
Oas30ItemsSchema items30 = (Oas30ItemsSchema) parent30.createItemsSchema();
if (!NodeCompat.isNullOrUndefined(parent30.items) && NodeCompat.isNode(parent30.items)) {
List<Oas30ItemsSchema> items = new ArrayList<>();
items.add(items30);
parent30.items = items;
} else {
parent30.items = items30;
}
this.toSchema(node, items30, true);
this.mapNode(node, items30);
}
use of io.apicurio.datamodels.openapi.v3.models.Oas30Schema in project apicurio-data-models by Apicurio.
the class Oas20to30TransformationVisitor method visitPropertySchema.
/**
* @see io.apicurio.datamodels.openapi.visitors.IOasVisitor#visitPropertySchema(io.apicurio.datamodels.core.models.common.IPropertySchema)
*/
@Override
public void visitPropertySchema(IPropertySchema node) {
Oas20PropertySchema ps20 = (Oas20PropertySchema) node;
Oas30Schema parent30 = (Oas30Schema) this.lookup(ps20.parent());
Oas30PropertySchema property30 = (Oas30PropertySchema) parent30.createPropertySchema(ps20.getPropertyName());
parent30.addProperty(ps20.getPropertyName(), property30);
this.toSchema(ps20, property30, true);
this.mapNode(ps20, property30);
}
Aggregations