use of com.github.victools.jsonschema.generator.impl.AttributeCollector in project jsonschema-generator by victools.
the class CustomEnumDefinitionProvider method provideCustomSchemaDefinition.
@Override
public CustomDefinition provideCustomSchemaDefinition(ResolvedType javaType, SchemaGenerationContext context) {
Object[] enumConstants = javaType.getErasedType().getEnumConstants();
if (enumConstants == null || enumConstants.length == 0) {
return null;
}
List<?> serializedJsonValues = null;
if (this.checkForJsonValueAnnotatedMethod) {
serializedJsonValues = this.getSerializedValuesFromJsonValue(javaType, enumConstants, context);
}
if (serializedJsonValues == null && this.checkForJsonPropertyAnnotations) {
serializedJsonValues = this.getSerializedValuesFromJsonProperty(javaType, enumConstants);
}
if (serializedJsonValues == null) {
return null;
}
ObjectNode customNode = context.getGeneratorConfig().createObjectNode().put(context.getKeyword(SchemaKeyword.TAG_TYPE), context.getKeyword(SchemaKeyword.TAG_TYPE_STRING));
AttributeCollector standardAttributeCollector = new AttributeCollector(context.getGeneratorConfig().getObjectMapper());
standardAttributeCollector.setEnum(customNode, serializedJsonValues, context);
return new CustomDefinition(customNode);
}
Aggregations