List of usage examples for com.fasterxml.jackson.module.jsonSchema.types ValueTypeSchema setDescription
public void setDescription(String description)
From source file:com.phoenixnap.oss.ramlapisync.naming.SchemaHelper.java
private static JsonSchema extractSchemaInternal(Type clazz, Type genericType, String responseDescription, JavaDocStore javaDocStore, ObjectMapper m) throws JsonMappingException { SchemaFactoryWrapper visitor = new SchemaFactoryWrapper(); if (genericType != null) { try {/*from ww w .j a v a 2 s . c om*/ m.acceptJsonFormatVisitor(m.constructType(genericType), visitor); } catch (Exception ex) { logger.error("Unable to add JSON visitor for " + genericType.toString()); } } try { m.acceptJsonFormatVisitor(m.constructType(clazz), visitor); } catch (Exception ex) { logger.error("Unable to add JSON visitor for " + clazz.toString()); } JsonSchema jsonSchema = visitor.finalSchema(); if (jsonSchema instanceof ObjectSchema && javaDocStore != null) { ObjectSchema objectSchema = (ObjectSchema) jsonSchema; if (objectSchema.getProperties() != null) { for (Entry<String, JsonSchema> cSchema : objectSchema.getProperties().entrySet()) { JavaDocEntry javaDocEntry = javaDocStore.getJavaDoc(cSchema.getKey()); if (javaDocEntry != null && StringUtils.hasText(javaDocEntry.getComment())) { cSchema.getValue().setDescription(javaDocEntry.getComment()); } } } } else if (jsonSchema instanceof ValueTypeSchema && StringUtils.hasText(responseDescription)) { ValueTypeSchema valueTypeSchema = (ValueTypeSchema) jsonSchema; valueTypeSchema.setDescription(responseDescription); } else if (jsonSchema instanceof ArraySchema && genericType != null) { ArraySchema arraySchema = (ArraySchema) jsonSchema; arraySchema.setItemsSchema(extractSchemaInternal(genericType, TypeHelper.inferGenericType(genericType), responseDescription, javaDocStore, m)); } return jsonSchema; }