Remove handler name, use the last path segment to name the payload class

This commit is contained in:
Johan Maasing 2025-03-20 19:22:41 +01:00
parent 92098b1a3b
commit 20aa2becfb
Signed by: johan
GPG key ID: FFD31BABEE2DEED2
6 changed files with 24 additions and 22 deletions

View file

@ -114,9 +114,10 @@ public class NodeTransformer {
SimpleNode handlerParseNode =
assertSimpleNodeType(
node.jjtGetChild(1),
TapirParserTreeConstants.JJTCOMPOUNDDATATYPE
TapirParserTreeConstants.JJTDATATYPEFIELDS
);
HandlerNode handlerNode = handleHandler(handlerParseNode);
List<FieldNode> fields = handleFields(handlerParseNode);
HandlerNode handlerNode = new HandlerNode(pathsNode.paths().getLast(), fields);
return new EndpointNode(pathsNode, handlerNode);
}

View file

@ -56,25 +56,26 @@ public class TargetGenerator {
cfg.setLogTemplateExceptions(false);
cfg.setWrapUncheckedExceptions(true);
cfg.setFallbackOnNullLoopVariable(false);
Template temp = cfg.getTemplate(ENDPOINTS_TEMPLATE_NAME);
List<Path> templates = Files
.list(this.templatePath)
.filter(Files::isRegularFile)
.filter(f -> f.getFileName().toString().endsWith(".ftl"))
.toList() ;
for (Path template : templates) {
for (Path templatePath : templates) {
try (var outputFile = Files.newBufferedWriter(
outputName(template),
outputName(templatePath),
StandardOpenOption.CREATE,
StandardOpenOption.TRUNCATE_EXISTING
)) {
if (this.verbose) {
System.out.println("Processing " + template);
System.out.println("Processing " + templatePath);
}
HashMap<String, Object> templateData = new HashMap<>();
templateData.put("endpoints", endpoints);
templateData.put("datatypes", dataTypes);
temp.process(templateData, outputFile);
cfg.getTemplate(
templatePath.getFileName().toString()
).process(templateData, outputFile);
}
}
} catch (TemplateException | IOException ex) {

View file

@ -90,7 +90,7 @@ void dataTypes() :
void endpoint() :
{}
{
path() <TRANSITION> compoundDataType()
path() <TRANSITION> <OPENPARANTHESIS> dataTypeFields() <CLOSEPARANTHESIS>
}
void endpoints() :