use of org.kie.kogito.codegen.json.JsonSchemaGenerator in project kogito-runtimes by kiegroup.
the class ProcessesAssetsProcessor method generateJsonSchema.
private Collection<GeneratedFile> generateJsonSchema(KogitoBuildContext context, IndexView index, Map<String, byte[]> generatedClasses) throws IOException {
ClassLoader cl = new InMemoryClassLoader(context.getClassLoader(), generatedClasses);
List<AnnotationInstance> annotations = new ArrayList<>();
annotations.addAll(index.getAnnotations(DotName.createSimple(ProcessInput.class.getCanonicalName())));
annotations.addAll(index.getAnnotations(DotName.createSimple(UserTask.class.getCanonicalName())));
List<Class<?>> annotatedClasses = annotations.stream().map(ann -> loadClassFromAnnotation(ann, cl)).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList());
JsonSchemaGenerator jsonSchemaGenerator = new JsonSchemaGenerator.ClassBuilder(annotatedClasses.stream()).withSchemaVersion(System.getProperty("kogito.jsonSchema.version")).build();
return jsonSchemaGenerator.generate();
}
Aggregations