Examples of JSONSchema


Examples of com.atlassian.json.schema.model.JsonSchema

                String ifaceJson = Files.toString(interfacesFile, Charsets.UTF_8);
                interfaceList = gson.fromJson(ifaceJson,InterfaceList.class);
            }

            JsonSchemaGenerator generator = provider.provide(getEnumCase(enumCase),interfaceList,schemaDocs,ignoreFilter);
            JsonSchema schema = generator.generateSchema(getRootClass());
           
            File rawFile = new File(rawOutput);
            File prettyFile = new File(prettyOutput);
           
            Files.createParentDirs(rawFile);
View Full Code Here

Examples of com.bazaarvoice.commons.data.model.json.schema.JSONSchema

                if (!objectType.getPatternProperties().isEmpty()) {
                    jsonObject.put("patternProperties", _patternPropertyMarshaller.toMappedJSONObject(objectType.getPatternProperties()));
                }

                JSONSchema additionalPropertiesSchema = objectType.getAdditionalPropertiesSchema();
                if (additionalPropertiesSchema == null) {
                    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));
                }
View Full Code Here

Examples of com.facebook.presto.hive.shaded.org.codehaus.jackson.schema.JsonSchema

        if (!(schemaNode instanceof ObjectNode)) {
            throw new IllegalArgumentException("Class " + type.getName() +
                    " would not be serialized as a JSON object and therefore has no schema");
        }

        return new JsonSchema((ObjectNode) schemaNode);
    }
View Full Code Here

Examples of com.facebook.presto.jdbc.internal.jackson.databind.jsonschema.JsonSchema

                    JsonSchema.getDefaultSchemaNode();
            if (!(schemaNode instanceof ObjectNode)) {
                throw new IllegalArgumentException("Class " + type.getName() +
                        " would not be serialized as a JSON object and therefore has no schema");
            }
            return new JsonSchema((ObjectNode) schemaNode);
        }
View Full Code Here

Examples of com.fasterxml.jackson.databind.jsonschema.JsonSchema

     * deserialized back to equal schema instance
     */
    public void testDeserializeSimple() throws Exception
    {
        ObjectMapper mapper = new ObjectMapper();
        JsonSchema schema = mapper.generateJsonSchema(Schemable.class);
        assertNotNull(schema);

        String schemaStr = mapper.writeValueAsString(schema);
        assertNotNull(schemaStr);
        JsonSchema result = mapper.readValue(schemaStr, JsonSchema.class);
        assertEquals("Trying to read from '"+schemaStr+"'", schema, result);
    }
View Full Code Here

Examples of com.fasterxml.jackson.databind.jsonschema.JsonSchema

                JsonSchema.getDefaultSchemaNode();
        if (!(schemaNode instanceof ObjectNode)) {
            throw new IllegalArgumentException("Class " + type.getName() +
                    " would not be serialized as a JSON object and therefore has no schema");
        }
        return new JsonSchema((ObjectNode) schemaNode);
    }
View Full Code Here

Examples of com.fasterxml.jackson.databind.jsonschema.JsonSchema

        String className = ((ScalarNode) node).getValue();
        try
        {
            Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
            ObjectMapper objectMapper = new ObjectMapper();
            JsonSchema jsonSchema = objectMapper.generateJsonSchema(clazz);
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            objectMapper.writeValue(baos, jsonSchema);
            String schema = baos.toString();
            return new ScalarNode(Tag.STR, schema, node.getStartMark(), node.getEndMark(), ((ScalarNode) node).getStyle());
        }
View Full Code Here

Examples of com.fasterxml.jackson.module.jsonSchema.JsonSchema

                continue;
            }
            try {
                SchemaFactoryWrapper visitor = new SchemaFactoryWrapper();
                mapper.acceptJsonFormatVisitor(mapper.constructType(type), visitor);
                final JsonSchema schema = visitor.finalSchema();
                models.put(type.getSimpleName(), schema);
            } catch (JsonMappingException e) {
                LOG.error("Error generating model schema. Ignoring this model, this will likely break the API browser.", e);
            }
View Full Code Here

Examples of com.fasterxml.jackson.module.jsonSchema.JsonSchema

    {
        try
        {
            TypeIdSchemaFactoryWrapper visitor = new TypeIdSchemaFactoryWrapper();
            objectMapper.acceptJsonFormatVisitor(type, visitor);
            JsonSchema jsonSchema = visitor.finalSchema();

            return jsonSchema.asObjectSchema();
        }
        catch (JsonMappingException e)
        {
            logger.warn("Error generating model for type {}",type);
        }
View Full Code Here

Examples of com.fasterxml.jackson.module.jsonSchema.JsonSchema

        Map<String,Model> modelMap = new HashMap<String, Model>();
        Map<String,JsonSchema> properties = new LinkedHashMap<String, JsonSchema>();

        for (Map.Entry<String, JsonSchema> entry : objectSchema.getProperties().entrySet())
        {
            JsonSchema schema = entry.getValue();
            if(schema.isObjectSchema())
            {
                JsonSchema temp = new ReferenceSchema();
                temp.set$ref(schema.getId());
                properties.put(entry.getKey(),temp);
                modelMap.putAll(buildModels(schema.getId(),schema.asObjectSchema()));
            }
            else if(schema.isArraySchema() && schema.asArraySchema().getItems().isSingleItems() && schema.asArraySchema().getItems().asSingleItems().getSchema().isObjectSchema())
            {
                ObjectSchema entrySchema = (ObjectSchema) schema.asArraySchema().getItems().asSingleItems().getSchema();

                ArraySchema arraySchema = new ArraySchema();
                JsonSchema temp = new ReferenceSchema();
                temp.set$ref(entrySchema.getId());
                arraySchema.setItemsSchema(temp);
                properties.put(entry.getKey(),arraySchema);

                modelMap.putAll(buildModels(entrySchema.getId(), entrySchema));
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.