Skip to content

Commit c4044bc

Browse files
committed
[Issue #429] Added Micronaut Codegen and its templates
1 parent dd99bfe commit c4044bc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2193
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package io.swagger.codegen.v3.generators.handlebars.lambda;
2+
3+
import com.github.jknack.handlebars.Lambda;
4+
import com.github.jknack.handlebars.Template;
5+
6+
import java.io.IOException;
7+
8+
/**
9+
* @author Franz See <[email protected]> <https://see.net.ph>
10+
*/
11+
public class CapitaliseLambda extends LowercaseLambda implements Lambda {
12+
13+
@Override
14+
public Object apply(Object o, Template template) throws IOException {
15+
String text = (String) super.apply(o, template);
16+
if (text.length() == 1) {
17+
text = String.valueOf(Character.toUpperCase(text.charAt(0)));
18+
} else if (text.length() > 1) {
19+
text = Character.toUpperCase(text.charAt(0)) + text.substring(1);
20+
}
21+
return text;
22+
}
23+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package io.swagger.codegen.v3.generators.handlebars.lambda;
2+
3+
import com.github.jknack.handlebars.Lambda;
4+
import com.github.jknack.handlebars.Template;
5+
import io.swagger.codegen.v3.CodegenConfig;
6+
7+
import java.io.IOException;
8+
import java.util.regex.Matcher;
9+
10+
/**
11+
* @author Franz See <[email protected]> <https://see.net.ph>
12+
*/
13+
public class EscapeDoubleQuotesLambda implements Lambda {
14+
15+
private CodegenConfig generator = null;
16+
17+
public EscapeDoubleQuotesLambda() {
18+
19+
}
20+
21+
public EscapeDoubleQuotesLambda generator(final CodegenConfig generator) {
22+
this.generator = generator;
23+
return this;
24+
}
25+
26+
@Override
27+
public Object apply(Object o, Template template) throws IOException {
28+
String text = template.apply(o);
29+
if (text == null || text.length() == 0) {
30+
return text;
31+
}
32+
text = text.replaceAll("\"", Matcher.quoteReplacement("\\\""));
33+
if (generator != null && generator.reservedWords().contains(text)) {
34+
text = generator.escapeReservedWord(text);
35+
}
36+
37+
return text;
38+
}
39+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package io.swagger.codegen.v3.generators.handlebars.lambda;
2+
3+
import com.github.jknack.handlebars.Lambda;
4+
import com.github.jknack.handlebars.Template;
5+
import io.swagger.codegen.v3.CodegenConfig;
6+
7+
import java.io.IOException;
8+
9+
/**
10+
* @author Franz See <[email protected]> <https://see.net.ph>
11+
*/
12+
public class RemoveLineBreakLambda implements Lambda {
13+
14+
private CodegenConfig generator = null;
15+
16+
public RemoveLineBreakLambda() {
17+
18+
}
19+
20+
public RemoveLineBreakLambda generator(final CodegenConfig generator) {
21+
this.generator = generator;
22+
return this;
23+
}
24+
25+
@Override
26+
public Object apply(Object o, Template template) throws IOException {
27+
String text = template.apply(o);
28+
if (text == null || text.length() == 0) {
29+
return text;
30+
}
31+
text = text.replaceAll("\\r|\\n", "");
32+
if (generator != null && generator.reservedWords().contains(text)) {
33+
text = generator.escapeReservedWord(text);
34+
}
35+
36+
return text;
37+
}
38+
}

0 commit comments

Comments
 (0)