Package com.bazaarvoice.commons.data.model.json.schema.types

Examples of com.bazaarvoice.commons.data.model.json.schema.types.JSONSchemaArrayType


                    jsonObject.put("additionalProperties", false);
                } else if (!additionalPropertiesSchema.isEmpty()) {
                    jsonObject.put("additionalProperties", toJSONObject(additionalPropertiesSchema, false));
                }
            } else if (type instanceof JSONSchemaArrayType) {
                JSONSchemaArrayType arrayType = (JSONSchemaArrayType) type;

                if (arrayType.isTuple()) {
                    jsonObject.put("items", toJSONArray(arrayType.getItems(), false));

                    JSONSchema additionalItemsSchema = arrayType.getAdditionalItemsSchema();
                    if (additionalItemsSchema == null) {
                        jsonObject.put("additionalItems", false);
                    } else if (!additionalItemsSchema.isEmpty()) {
                        jsonObject.put("additionalItems", toJSONObject(additionalItemsSchema, false));
                    }
                } else {
                    jsonObject.put("items", toJSONObject(arrayType.getItem(), false));
                }
            }
        }

        if (!enums.isEmpty()) {
View Full Code Here


                    objectType.setAdditionalPropertiesSchema(null);
                } else if (additionalProperties != null && additionalProperties != JSONObject.NULL) {
                    throw new IllegalArgumentException("Unsupported additional properties: " + additionalProperties);
                }
            } else if (type instanceof JSONSchemaArrayType) {
                JSONSchemaArrayType arrayType = (JSONSchemaArrayType) type;

                Object items = jsonObject.opt("items");

                if (items instanceof JSONObject) {
                    arrayType.setItem(fromJSONObject((JSONObject) items));
                } else if (items instanceof JSONArray || items instanceof Collection) {
                    arrayType.setItems(fromJSONArray((JSONArray) items));

                    Object additionalItems = jsonObject.opt("additionalItems");
                    if (additionalItems instanceof JSONObject) {
                        arrayType.additionalItemsSchema(fromJSONObject((JSONObject) additionalItems));
                    } else if (additionalItems instanceof Boolean && !((Boolean) additionalItems)) {
                        arrayType.additionalItemsSchema(null);
                    } else if (additionalItems != null && additionalItems != JSONObject.NULL) {
                        throw new IllegalArgumentException("Unsupported additional items: " + additionalItems);
                    } else {
                        arrayType.additionalItemsSchema(new JSONSchema());
                    }
                }
            }
        }
View Full Code Here

    public static JSONSchema newUniformObjectSchema(JSONSchema additionalProperties) {
        return newSimpleSchema(new JSONSchemaObjectType().additionalPropertiesSchema(additionalProperties));
    }

    public static JSONSchema newArraySchema(JSONSchema... itemSchemas) {
        return newSimpleSchema(new JSONSchemaArrayType().items(itemSchemas));
    }
View Full Code Here

                    jsonObject.put("additionalProperties", false);
                } else if (!additionalPropertiesSchema.isEmpty()) {
                    jsonObject.put("additionalProperties", toJSONObject(additionalPropertiesSchema, false));
                }
            } else if (type instanceof JSONSchemaArrayType) {
                JSONSchemaArrayType arrayType = (JSONSchemaArrayType) type;

                if (arrayType.isTuple()) {
                    jsonObject.put("items", toJSONArray(arrayType.getItems(), false));

                    JSONSchema additionalItemsSchema = arrayType.getAdditionalItemsSchema();
                    if (additionalItemsSchema == null) {
                        jsonObject.put("additionalItems", false);
                    } else if (!additionalItemsSchema.isEmpty()) {
                        jsonObject.put("additionalItems", toJSONObject(additionalItemsSchema, false));
                    }
                } else {
                    jsonObject.put("items", toJSONObject(arrayType.getItem(), false));
                }
            }
        }

        if (!enums.isEmpty()) {
View Full Code Here

                    objectType.setAdditionalPropertiesSchema(null);
                } else if (additionalProperties != null && additionalProperties != JSONObject.NULL) {
                    throw new IllegalArgumentException("Unsupported additional properties: " + additionalProperties);
                }
            } else if (type instanceof JSONSchemaArrayType) {
                JSONSchemaArrayType arrayType = (JSONSchemaArrayType) type;

                Object items = jsonObject.opt("items");

                if (items instanceof JSONObject) {
                    arrayType.setItem(fromJSONObject((JSONObject) items));
                } else if (items instanceof JSONArray || items instanceof Collection) {
                    arrayType.setItems(fromJSONArray((JSONArray) items));

                    Object additionalItems = jsonObject.opt("additionalItems");
                    if (additionalItems instanceof JSONObject) {
                        arrayType.additionalItemsSchema(fromJSONObject((JSONObject) additionalItems));
                    } else if (additionalItems instanceof Boolean && !((Boolean) additionalItems)) {
                        arrayType.additionalItemsSchema(null);
                    } else if (additionalItems != null && additionalItems != JSONObject.NULL) {
                        throw new IllegalArgumentException("Unsupported additional items: " + additionalItems);
                    } else {
                        arrayType.additionalItemsSchema(new JSONSchema());
                    }
                }
            }
        }
View Full Code Here

TOP

Related Classes of com.bazaarvoice.commons.data.model.json.schema.types.JSONSchemaArrayType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.