Skip to content
Permalink
Browse files

[Issue swagger-api#429] Added Micronaut Codegen and its templates

  • Loading branch information...
franz-see committed Jul 22, 2019
1 parent 04ad1ce commit d0ba8a8719f32f3c0e6c1715564836ad19cab623
Showing with 2,193 additions and 0 deletions.
  1. +23 −0 src/main/java/io/swagger/codegen/v3/generators/handlebars/lambda/CapitaliseLambda.java
  2. +39 −0 src/main/java/io/swagger/codegen/v3/generators/handlebars/lambda/EscapeDoubleQuotesLambda.java
  3. +38 −0 src/main/java/io/swagger/codegen/v3/generators/handlebars/lambda/RemoveLineBreakLambda.java
  4. +527 −0 src/main/java/io/swagger/codegen/v3/generators/java/MicronautCodegen.java
  5. +1 −0 src/main/resources/META-INF/services/io.swagger.codegen.v3.CodegenConfig
  6. +18 −0 src/main/resources/handlebars/JavaMicronaut/README.mustache
  7. +22 −0 src/main/resources/handlebars/JavaMicronaut/RFC3339DateFormat.mustache
  8. +67 −0 src/main/resources/handlebars/JavaMicronaut/api.mustache
  9. +10 −0 src/main/resources/handlebars/JavaMicronaut/apiException.mustache
  10. +65 −0 src/main/resources/handlebars/JavaMicronaut/apiResponseMessage.mustache
  11. +39 −0 src/main/resources/handlebars/JavaMicronaut/api_test.mustache
  12. +22 −0 src/main/resources/handlebars/JavaMicronaut/application.mustache
  13. +6 −0 src/main/resources/handlebars/JavaMicronaut/beanValidation.mustache
  14. +20 −0 src/main/resources/handlebars/JavaMicronaut/beanValidationCore.mustache
  15. +1 −0 src/main/resources/handlebars/JavaMicronaut/beanValidationPathParams.mustache
  16. +1 −0 src/main/resources/handlebars/JavaMicronaut/beanValidationQueryParams.mustache
  17. +1 −0 src/main/resources/handlebars/JavaMicronaut/bodyParams.mustache
  18. +232 −0 src/main/resources/handlebars/JavaMicronaut/customInstantDeserializer.mustache
  19. +44 −0 src/main/resources/handlebars/JavaMicronaut/enumClass.mustache
  20. +42 −0 src/main/resources/handlebars/JavaMicronaut/enumOuterClass.mustache
  21. +1 −0 src/main/resources/handlebars/JavaMicronaut/exampleReturnTypes.mustache
  22. +1 −0 src/main/resources/handlebars/JavaMicronaut/formParams.mustache
  23. +3 −0 src/main/resources/handlebars/JavaMicronaut/generatedAnnotation.mustache
  24. +1 −0 src/main/resources/handlebars/JavaMicronaut/headerParams.mustache
  25. +26 −0 src/main/resources/handlebars/JavaMicronaut/homeController.mustache
  26. +1 −0 src/main/resources/handlebars/JavaMicronaut/implicitHeader.mustache
  27. +27 −0 src/main/resources/handlebars/JavaMicronaut/mainApplication.mustache
  28. +33 −0 src/main/resources/handlebars/JavaMicronaut/model.mustache
  29. +310 −0 src/main/resources/handlebars/JavaMicronaut/mvnw
  30. +182 −0 src/main/resources/handlebars/JavaMicronaut/mvnw.cmd
  31. +10 −0 src/main/resources/handlebars/JavaMicronaut/notFoundException.mustache
  32. +1 −0 src/main/resources/handlebars/JavaMicronaut/optionalDataType.mustache
  33. +1 −0 src/main/resources/handlebars/JavaMicronaut/pathParams.mustache
  34. +140 −0 src/main/resources/handlebars/JavaMicronaut/pojo.mustache
  35. +191 −0 src/main/resources/handlebars/JavaMicronaut/pom.mustache
  36. +1 −0 src/main/resources/handlebars/JavaMicronaut/project/build.properties
  37. +9 −0 src/main/resources/handlebars/JavaMicronaut/project/plugins.sbt
  38. +1 −0 src/main/resources/handlebars/JavaMicronaut/queryParams.mustache
  39. +1 −0 src/main/resources/handlebars/JavaMicronaut/returnTypes.mustache
  40. +7 −0 src/main/resources/handlebars/JavaMicronaut/typeInfoAnnotation.mustache
  41. +22 −0 src/main/resources/handlebars/JavaMicronaut/unsupportedOperationExceptionHandler.mustache
  42. +6 −0 src/main/resources/handlebars/JavaMicronaut/xmlAnnotation.mustache
@@ -0,0 +1,23 @@
package io.swagger.codegen.v3.generators.handlebars.lambda;

import com.github.jknack.handlebars.Lambda;
import com.github.jknack.handlebars.Template;

import java.io.IOException;

/**
* @author Franz See <franz@see.net.ph> <https://see.net.ph>
*/
public class CapitaliseLambda extends LowercaseLambda implements Lambda {

@Override
public Object apply(Object o, Template template) throws IOException {
String text = (String) super.apply(o, template);
if (text.length() == 1) {
text = String.valueOf(Character.toUpperCase(text.charAt(0)));
} else if (text.length() > 1) {
text = Character.toUpperCase(text.charAt(0)) + text.substring(1);
}
return text;
}
}
@@ -0,0 +1,39 @@
package io.swagger.codegen.v3.generators.handlebars.lambda;

import com.github.jknack.handlebars.Lambda;
import com.github.jknack.handlebars.Template;
import io.swagger.codegen.v3.CodegenConfig;

import java.io.IOException;
import java.util.regex.Matcher;

/**
* @author Franz See <franz@see.net.ph> <https://see.net.ph>
*/
public class EscapeDoubleQuotesLambda implements Lambda {

private CodegenConfig generator = null;

public EscapeDoubleQuotesLambda() {

}

public EscapeDoubleQuotesLambda generator(final CodegenConfig generator) {
this.generator = generator;
return this;
}

@Override
public Object apply(Object o, Template template) throws IOException {
String text = template.apply(o);
if (text == null || text.length() == 0) {
return text;
}
text = text.replaceAll("\"", Matcher.quoteReplacement("\\\""));
if (generator != null && generator.reservedWords().contains(text)) {
text = generator.escapeReservedWord(text);
}

return text;
}
}
@@ -0,0 +1,38 @@
package io.swagger.codegen.v3.generators.handlebars.lambda;

import com.github.jknack.handlebars.Lambda;
import com.github.jknack.handlebars.Template;
import io.swagger.codegen.v3.CodegenConfig;

import java.io.IOException;

/**
* @author Franz See <franz@see.net.ph> <https://see.net.ph>
*/
public class RemoveLineBreakLambda implements Lambda {

private CodegenConfig generator = null;

public RemoveLineBreakLambda() {

}

public RemoveLineBreakLambda generator(final CodegenConfig generator) {
this.generator = generator;
return this;
}

@Override
public Object apply(Object o, Template template) throws IOException {
String text = template.apply(o);
if (text == null || text.length() == 0) {
return text;
}
text = text.replaceAll("\\r|\\n", "");
if (generator != null && generator.reservedWords().contains(text)) {
text = generator.escapeReservedWord(text);
}

return text;
}
}

0 comments on commit d0ba8a8

Please sign in to comment.
You can’t perform that action at this time.