ru.curs.hurdygurdy.KotlinCodegen Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hurdy-gurdy Show documentation
Show all versions of hurdy-gurdy Show documentation
Client/server code generator for OpenAPI
package ru.curs.hurdygurdy;
import com.squareup.kotlinpoet.FileSpec;
import com.squareup.kotlinpoet.TypeSpec;
import java.io.IOException;
import java.nio.file.Path;
import java.util.List;
import java.util.function.BiConsumer;
public class KotlinCodegen extends Codegen {
public KotlinCodegen(String rootPackage, boolean generateResponseParameter, boolean generateApiInterface) {
super(rootPackage, new TypeProducersFactory<>() {
@Override
public TypeDefiner createTypeDefiner(BiConsumer typeSpecBiConsumer) {
return new KotlinTypeDefiner(rootPackage, typeSpecBiConsumer);
}
@Override
public List> typeSpecExtractors(TypeDefiner typeDefiner) {
return List.of(new KotlinDTOExtractor(typeDefiner),
new KotlinAPIExtractor(typeDefiner, generateResponseParameter, generateApiInterface));
}
});
}
@Override
void writeFile(Path resultDirectory, String packageName, TypeSpec typeSpec) throws IOException {
var ktFile = FileSpec.get(packageName, typeSpec);
ktFile.writeTo(resultDirectory);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy