private static boolean schemaIsNotSpecified(final Model schema) { if (schema == null) { return true; } if (schema instanceof ArrayModel) { return ((ArrayModel) schema).getItems() == null; } final Map<String, Property> properties = schema.getProperties(); final boolean noProperties = properties == null || properties.isEmpty(); final boolean noReference = schema.getReference() == null; return noProperties && noReference; }
private static JsonNode createSchemaFromModel(final String specification, final Model schema) { if (schema instanceof ArrayModel) { final Property items = ((ArrayModel) schema).getItems(); return createSchemaFromProperty(specification, items); } else if (schema instanceof ModelImpl) { return createSchemaFromModelImpl(schema); } final String title = Optional.ofNullable(schema.getTitle()).orElse(schema.getReference().replaceAll("^.*/", "")); return createSchemaFromReference(specification, title, schema.getReference()); }
private static boolean schemaIsNotSpecified(final Model schema) { if (schema == null) { return true; } if (schema instanceof ArrayModel) { return ((ArrayModel) schema).getItems() == null; } final Map<String, Property> properties = schema.getProperties(); final boolean noProperties = properties == null || properties.isEmpty(); final boolean noReference = schema.getReference() == null; return noProperties && noReference; }
private static boolean schemaIsNotSpecified(final Model schema) { if (schema == null) { return true; } if (schema instanceof ArrayModel) { return ((ArrayModel) schema).getItems() == null; } final Map<String, Property> properties = schema.getProperties(); final boolean noProperties = properties == null || properties.isEmpty(); final boolean noReference = schema.getReference() == null; return noProperties && noReference; }
private static JsonNode createSchemaFromModel(final String specification, final Model schema) { if (schema instanceof ArrayModel) { final Property items = ((ArrayModel) schema).getItems(); return createSchemaFromProperty(specification, items); } else if (schema instanceof ModelImpl) { return createSchemaFromModelImpl(schema); } final String title = Optional.ofNullable(schema.getTitle()).orElse(schema.getReference().replaceAll("^.*/", "")); return createSchemaFromReference(specification, title, schema.getReference()); }
private static String determineTitleOf(final String name, final Model schema) { final String title = schema.getTitle(); if (title != null) { return title; } final String description = schema.getDescription(); if (description != null) { return description; } final String reference = schema.getReference(); if (reference != null) { return reference.replaceAll("^.*/", ""); } return name; }
private static String determineTitleOf(final String name, final Model schema) { final String title = schema.getTitle(); if (title != null) { return title; } final String description = schema.getDescription(); if (description != null) { return description; } final String reference = schema.getReference(); if (reference != null) { return reference.replaceAll("^.*/", ""); } return name; }
private static ObjectNode createSchemaFromModel(final ObjectNode json, final String name, final Model schema) { if (schema instanceof ArrayModel) { final Property items = ((ArrayModel) schema).getItems(); final ObjectNode itemSchema = createSchemaFromProperty(json, name, items); itemSchema.remove(Arrays.asList("$schema", "title")); final ObjectNode jsonSchema = JsonNodeFactory.instance.objectNode(); jsonSchema.put("type", "array"); jsonSchema.set("items", itemSchema); return jsonSchema; } else if (schema instanceof ModelImpl) { return createSchemaFromModelImpl(name, schema); } final String title = determineTitleOf(name, schema); return JsonSchemaHelper.resolveSchemaForReference(json, title, schema.getReference()); }
private static ObjectNode createSchemaFromModel(final ObjectNode json, final String name, final Model schema) { if (schema instanceof ArrayModel) { final Property items = ((ArrayModel) schema).getItems(); return createSchemaFromProperty(json, name, items); } else if (schema instanceof ModelImpl) { return createSchemaFromModelImpl(name, schema); } final String title = determineTitleOf(name, schema); return resolveSchemaForReference(json, title, schema.getReference()); }