use of com.fasterxml.jackson.core.JsonPointer in project KaiZen-OpenAPI-Editor by RepreZen.
the class Validator method checkObjectTypeDefinition.
/**
* Validates an object type definition.
*
* @param errors
* @param node
*/
protected void checkObjectTypeDefinition(Set<SwaggerError> errors, AbstractNode node) {
if (node instanceof ObjectNode) {
JsonPointer ptr = node.getPointer();
if (ptr != null && ValidationUtil.isInDefinition(ptr.toString())) {
checkMissingType(errors, node);
checkMissingRequiredProperties(errors, node);
}
}
}
use of com.fasterxml.jackson.core.JsonPointer in project KaiZen-OpenAPI-Editor by RepreZen.
the class CompositeSchema method getType.
/**
* Returns the type of a node.
*
* <br/>
*
* Note: this method should be used only during initialization of a model.
*
* @param node
* @return node's type
*/
public TypeDefinition getType(AbstractNode node) {
JsonPointer pointer = node.getPointer();
if (JsonPointer.compile("").equals(pointer)) {
return swaggerType.getType();
}
String[] paths = pointer.toString().substring(1).split("/");
TypeDefinition current = swaggerType.getType();
if (current != null) {
for (String property : paths) {
TypeDefinition next = current.getPropertyType(property);
// not found, we stop here
if (next == null) {
break;
}
current = next;
}
}
return current;
}
use of com.fasterxml.jackson.core.JsonPointer in project KaiZen-OpenAPI-Editor by RepreZen.
the class CompositeSchema method resolve.
/**
* Returns the type definition reachable by the JSON reference. The context type is used to identify the schema that
* will be used to resolve the referenced type.
*
* @param context
* @param reference
* @return type
*/
public TypeDefinition resolve(TypeDefinition context, String reference) {
String schemaId = baseURI(reference);
JsonPointer pointer = pointer(reference);
JsonSchema schema = schemaId == null ? context.getSchema() : getSchema(schemaId);
if (pointer == null) {
return schema.getType();
}
return schema.get(pointer);
}
Aggregations