From d825b967202c93643c99f690af8e2d21cd81af01 Mon Sep 17 00:00:00 2001 From: xhh Date: Thu, 2 Jul 2015 12:00:18 +0800 Subject: [PATCH] Sanitize API class name in Jax RS server codegen --- .../io/swagger/codegen/languages/JaxRSServerCodegen.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JaxRSServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JaxRSServerCodegen.java index ac54115745..8f0a623f08 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JaxRSServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JaxRSServerCodegen.java @@ -166,6 +166,15 @@ public class JaxRSServerCodegen extends JavaClientCodegen implements CodegenConf return objs; } + @Override + public String toApiName(String name) { + if (name.length() == 0) { + return "DefaultApi"; + } + name = name.replaceAll("[^a-zA-Z ]+", "_"); + return camelize(name) + "Api"; + } + @Override public String apiFilename(String templateName, String tag) {