io.swagger.codegen.CodegenConstants Java Examples
The following examples show how to use
io.swagger.codegen.CodegenConstants.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractJavaJAXRSServerCodegen.java From TypeScript-Microservices with MIT License | 6 votes |
public AbstractJavaJAXRSServerCodegen() { super(); sourceFolder = "src/gen/java"; invokerPackage = "io.swagger.api"; artifactId = "swagger-jaxrs-server"; dateLibrary = "legacy"; //TODO: add joda support to all jax-rs apiPackage = "io.swagger.api"; modelPackage = "io.swagger.model"; additionalProperties.put("title", title); // java inflector uses the jackson lib additionalProperties.put("jackson", "true"); cliOptions.add(new CliOption(CodegenConstants.IMPL_FOLDER, CodegenConstants.IMPL_FOLDER_DESC)); cliOptions.add(new CliOption("title", "a title describing the application")); cliOptions.add(CliOption.newBoolean(USE_BEANVALIDATION, "Use BeanValidation API annotations")); cliOptions.add(new CliOption("serverPort", "The port on which the server should be started")); }
Example #2
Source File: SpringServerCodeGenImpl.java From sc-generator with Apache License 2.0 | 6 votes |
public SpringServerCodeGenImpl() { super(); additionalProperties.put(FULL_JAVA_UTIL,"true"); additionalProperties.put(CodegenConstants.SERIALIZABLE_MODEL, serializableModel); typeMapping.put("Map","java.util.Map"); typeMapping.put("HashMap","java.util.Map"); typeMapping.put("hashMap","java.util.Map"); typeMapping.put("jSONObject","java.util.Map"); typeMapping.put("JSONObject","java.util.Map"); typeMapping.put("JSONArray","java.util.List"); typeMapping.put("jSONArray","java.util.List"); typeMapping.put("Iterable","java.util.List"); typeMapping.put("iterable","java.util.List"); typeMapping.put("iterable","java.util.List"); typeMapping.put("Set","java.util.Set"); typeMapping.put("set","java.util.Set"); }
Example #3
Source File: JavaClientCodegenImpl.java From sc-generator with Apache License 2.0 | 6 votes |
public JavaClientCodegenImpl() { additionalProperties.put(FULL_JAVA_UTIL,"true"); additionalProperties.put(CodegenConstants.SERIALIZABLE_MODEL, serializableModel); typeMapping.put("Map","java.util.Map"); typeMapping.put("HashMap","java.util.Map"); typeMapping.put("hashMap","java.util.Map"); typeMapping.put("jSONObject","java.util.Map"); typeMapping.put("JSONObject","java.util.Map"); typeMapping.put("JSONArray","java.util.List"); typeMapping.put("jSONArray","java.util.List"); typeMapping.put("Iterable","java.util.List"); typeMapping.put("iterable","java.util.List"); typeMapping.put("iterable","java.util.List"); typeMapping.put("Set","java.util.Set"); typeMapping.put("set","java.util.Set"); }
Example #4
Source File: AbstractJavaCodegen.java From TypeScript-Microservices with MIT License | 6 votes |
private void sanitizeConfig() { // Sanitize any config options here. We also have to update the additionalProperties because // the whole additionalProperties object is injected into the main object passed to the mustache layer this.setApiPackage(sanitizePackageName(apiPackage)); if (additionalProperties.containsKey(CodegenConstants.API_PACKAGE)) { this.additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage); } this.setModelPackage(sanitizePackageName(modelPackage)); if (additionalProperties.containsKey(CodegenConstants.MODEL_PACKAGE)) { this.additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage); } this.setInvokerPackage(sanitizePackageName(invokerPackage)); if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) { this.additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); } }
Example #5
Source File: AbstractJavaJAXRSServerCodegen.java From TypeScript-Microservices with MIT License | 6 votes |
@Override public void processOpts() { super.processOpts(); if (additionalProperties.containsKey(CodegenConstants.IMPL_FOLDER)) { implFolder = (String) additionalProperties.get(CodegenConstants.IMPL_FOLDER); } if (additionalProperties.containsKey(USE_BEANVALIDATION)) { this.setUseBeanValidation(convertPropertyToBoolean(USE_BEANVALIDATION)); } if (useBeanValidation) { writePropertyBack(USE_BEANVALIDATION, useBeanValidation); } }
Example #6
Source File: CodeGenMojo.java From TypeScript-Microservices with MIT License | 6 votes |
private void addCompileSourceRootIfConfigured() { if (addCompileSourceRoot) { final Object sourceFolderObject = configOptions == null ? null : configOptions .get(CodegenConstants.SOURCE_FOLDER); final String sourceFolder = sourceFolderObject == null ? "src/main/java" : sourceFolderObject.toString(); String sourceJavaFolder = output.toString() + "/" + sourceFolder; project.addCompileSourceRoot(sourceJavaFolder); } // Reset all environment variables to their original value. This prevents unexpected // behaviour // when running the plugin multiple consecutive times with different configurations. for (Map.Entry<String, String> entry : originalEnvironmentVariables.entrySet()) { if (entry.getValue() == null) { System.clearProperty(entry.getKey()); } else { System.setProperty(entry.getKey(), entry.getValue()); } } }
Example #7
Source File: SwaggerCodegen.java From mdw with Apache License 2.0 | 5 votes |
public SwaggerCodegen() { super(); embeddedTemplateDir = "codegen"; // standard opts to be overridden by user options outputFolder = "."; apiPackage = "com.centurylink.api.service"; modelPackage = "com.centurylink.api.model"; cliOptions.add(CliOption .newString(TRIM_API_PATHS, "Trim API paths and adjust package names accordingly") .defaultValue(Boolean.TRUE.toString())); additionalProperties.put(TRIM_API_PATHS, true); cliOptions.add(CliOption.newString(GENERATED_FLOW_BASE_PACKAGE, "Base package for generated microservice orchestration workflow processes")); // relevant once we submit a PR to swagger-code to become an official // java library supportedLibraries.put(NAME, getHelp()); setLibrary(NAME); CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use"); library.setDefault(NAME); library.setEnum(supportedLibraries); library.setDefault(NAME); cliOptions.add(library); }
Example #8
Source File: KotlinServerCodegen.java From TypeScript-Microservices with MIT License | 5 votes |
/** * Constructs an instance of `KotlinServerCodegen`. */ public KotlinServerCodegen() { super(); artifactId = "kotlin-server"; packageName = "io.swagger.server"; outputFolder = "generated-code" + File.separator + "kotlin-server"; modelTemplateFiles.put("model.mustache", ".kt"); apiTemplateFiles.put("api.mustache", ".kt"); embeddedTemplateDir = templateDir = "kotlin-server"; apiPackage = packageName + ".apis"; modelPackage = packageName + ".models"; supportedLibraries.put("ktor", "ktor framework"); // TODO: Configurable server engine. Defaults to netty in build.gradle. CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use"); library.setDefault(DEFAULT_LIBRARY); library.setEnum(supportedLibraries); cliOptions.add(library); addSwitch(Constants.AUTOMATIC_HEAD_REQUESTS, Constants.AUTOMATIC_HEAD_REQUESTS_DESC, getAutoHeadFeatureEnabled()); addSwitch(Constants.CONDITIONAL_HEADERS, Constants.CONDITIONAL_HEADERS_DESC, getConditionalHeadersFeatureEnabled()); addSwitch(Constants.HSTS, Constants.HSTS_DESC, getHstsFeatureEnabled()); addSwitch(Constants.CORS, Constants.CORS_DESC, getCorsFeatureEnabled()); addSwitch(Constants.COMPRESSION, Constants.COMPRESSION_DESC, getCompressionFeatureEnabled()); }
Example #9
Source File: AbstractScalaCodegen.java From TypeScript-Microservices with MIT License | 5 votes |
@Override public void processOpts() { super.processOpts(); if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)) { this.setSourceFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER)); } if (additionalProperties.containsKey(CodegenConstants.STRIP_PACKAGE_NAME) && "false".equalsIgnoreCase(additionalProperties.get(CodegenConstants.STRIP_PACKAGE_NAME).toString())) { this.stripPackageName = false; additionalProperties.put(CodegenConstants.STRIP_PACKAGE_NAME, false); LOGGER.warn("stripPackageName=false. Compilation errors may occur if API type names clash with types " + "in the default imports"); } }
Example #10
Source File: AbstractKotlinCodegen.java From TypeScript-Microservices with MIT License | 5 votes |
/** * Sets the naming convention for Kotlin enum properties * * @param enumPropertyNamingType The string representation of the naming convention, as defined by {@link CodegenConstants.ENUM_PROPERTY_NAMING_TYPE} */ public void setEnumPropertyNaming(final String enumPropertyNamingType) { try { this.enumPropertyNaming = CodegenConstants.ENUM_PROPERTY_NAMING_TYPE.valueOf(enumPropertyNamingType); } catch (IllegalArgumentException ex) { StringBuilder sb = new StringBuilder(enumPropertyNamingType + " is an invalid enum property naming option. Please choose from:"); for (CodegenConstants.ENUM_PROPERTY_NAMING_TYPE t : CodegenConstants.ENUM_PROPERTY_NAMING_TYPE.values()) { sb.append("\n ").append(t.name()); } throw new RuntimeException(sb.toString()); } }
Example #11
Source File: AbstractTypeScriptClientCodegen.java From TypeScript-Microservices with MIT License | 5 votes |
@Override public void processOpts() { super.processOpts(); if (additionalProperties.containsKey(CodegenConstants.MODEL_PROPERTY_NAMING)) { setModelPropertyNaming((String) additionalProperties.get(CodegenConstants.MODEL_PROPERTY_NAMING)); } if (additionalProperties.containsKey(CodegenConstants.SUPPORTS_ES6)) { setSupportsES6(Boolean.valueOf(additionalProperties.get(CodegenConstants.SUPPORTS_ES6).toString())); additionalProperties.put("supportsES6", getSupportsES6()); } }
Example #12
Source File: AbstractTypeScriptClientCodegen.java From TypeScript-Microservices with MIT License | 5 votes |
public String getNameUsingModelPropertyNaming(String name) { switch (CodegenConstants.MODEL_PROPERTY_NAMING_TYPE.valueOf(getModelPropertyNaming())) { case original: return name; case camelCase: return camelize(name, true); case PascalCase: return camelize(name); case snake_case: return underscore(name); default: throw new IllegalArgumentException("Invalid model property naming '" + name + "'. Must be 'original', 'camelCase', " + "'PascalCase' or 'snake_case'"); } }
Example #13
Source File: CsharpDotNet2ClientCodegen.java From TypeScript-Microservices with MIT License | 5 votes |
public CsharpDotNet2ClientCodegen() { super(); // clear import mapping (from default generator) as C# (2.0) does not use it // at the moment importMapping.clear(); modelTemplateFiles.put("model.mustache", ".cs"); apiTemplateFiles.put("api.mustache", ".cs"); setApiPackage(packageName + ".Api"); setModelPackage(packageName + ".Model"); setClientPackage(packageName + ".Client"); setSourceFolder("src" + File.separator + "main" + File.separator + "CsharpDotNet2"); modelDocTemplateFiles.put("model_doc.mustache", ".md"); apiDocTemplateFiles.put("api_doc.mustache", ".md"); cliOptions.clear(); cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "C# package name (convention: Camel.Case).") .defaultValue(packageName)); cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "C# package version.") .defaultValue(packageVersion)); cliOptions.add(new CliOption(CLIENT_PACKAGE, "C# client package name (convention: Camel.Case).") .defaultValue(clientPackage)); }
Example #14
Source File: StaticHtmlGenerator.java From TypeScript-Microservices with MIT License | 5 votes |
public StaticHtmlGenerator() { super(); outputFolder = "docs"; embeddedTemplateDir = templateDir = "htmlDocs"; defaultIncludes = new HashSet<String>(); cliOptions.add(new CliOption("appName", "short name of the application")); cliOptions.add(new CliOption("appDescription", "description of the application")); cliOptions.add(new CliOption("infoUrl", "a URL where users can get more information about the application")); cliOptions.add(new CliOption("infoEmail", "an email address to contact for inquiries about the application")); cliOptions.add(new CliOption("licenseInfo", "a short description of the license")); cliOptions.add(new CliOption("licenseUrl", "a URL pointing to the full license")); cliOptions.add(new CliOption(CodegenConstants.INVOKER_PACKAGE, CodegenConstants.INVOKER_PACKAGE_DESC)); cliOptions.add(new CliOption(CodegenConstants.GROUP_ID, CodegenConstants.GROUP_ID_DESC)); cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_ID, CodegenConstants.ARTIFACT_ID_DESC)); cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_VERSION, CodegenConstants.ARTIFACT_VERSION_DESC)); additionalProperties.put("appName", "Swagger Sample"); additionalProperties.put("appDescription", "A sample swagger server"); additionalProperties.put("infoUrl", "https://helloreverb.com"); additionalProperties.put("infoEmail", "[email protected]"); additionalProperties.put("licenseInfo", "All rights reserved"); additionalProperties.put("licenseUrl", "http://apache.org/licenses/LICENSE-2.0.html"); additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); additionalProperties.put(CodegenConstants.GROUP_ID, groupId); additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId); additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion); supportingFiles.add(new SupportingFile("index.mustache", "", "index.html")); reservedWords = new HashSet<String>(); languageSpecificPrimitives = new HashSet<String>(); importMapping = new HashMap<String, String>(); }
Example #15
Source File: AbstractTypeScriptClientCodegen.java From TypeScript-Microservices with MIT License | 4 votes |
public AbstractTypeScriptClientCodegen() { super(); // clear import mapping (from default generator) as TS does not use it // at the moment importMapping.clear(); supportsInheritance = true; setReservedWordsLowerCase(Arrays.asList( // local variable names used in API methods (endpoints) "varLocalPath", "queryParameters", "headerParams", "formParams", "useFormData", "varLocalDeferred", "requestOptions", // Typescript reserved words "abstract", "await", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue", "debugger", "default", "delete", "do", "double", "else", "enum", "export", "extends", "false", "final", "finally", "float", "for", "function", "goto", "if", "implements", "import", "in", "instanceof", "int", "interface", "let", "long", "native", "new", "null", "package", "private", "protected", "public", "return", "short", "static", "super", "switch", "synchronized", "this", "throw", "transient", "true", "try", "typeof", "var", "void", "volatile", "while", "with", "yield")); languageSpecificPrimitives = new HashSet<>(Arrays.asList( "string", "String", "boolean", "Boolean", "Double", "Integer", "Long", "Float", "Object", "Array", "Date", "number", "any", "File", "Error", "Map" )); languageGenericTypes = new HashSet<String>(Arrays.asList( "Array" )); instantiationTypes.put("array", "Array"); typeMapping = new HashMap<String, String>(); typeMapping.put("Array", "Array"); typeMapping.put("array", "Array"); typeMapping.put("List", "Array"); typeMapping.put("boolean", "boolean"); typeMapping.put("string", "string"); typeMapping.put("int", "number"); typeMapping.put("float", "number"); typeMapping.put("number", "number"); typeMapping.put("long", "number"); typeMapping.put("short", "number"); typeMapping.put("char", "string"); typeMapping.put("double", "number"); typeMapping.put("object", "any"); typeMapping.put("integer", "number"); typeMapping.put("Map", "any"); typeMapping.put("date", "string"); typeMapping.put("DateTime", "Date"); //TODO binary should be mapped to byte array // mapped to String as a workaround typeMapping.put("binary", "string"); typeMapping.put("ByteArray", "string"); typeMapping.put("UUID", "string"); typeMapping.put("File", "any"); typeMapping.put("Error", "Error"); cliOptions.add(new CliOption(CodegenConstants.MODEL_PROPERTY_NAMING, CodegenConstants.MODEL_PROPERTY_NAMING_DESC).defaultValue("camelCase")); cliOptions.add(new CliOption(CodegenConstants.SUPPORTS_ES6, CodegenConstants.SUPPORTS_ES6_DESC).defaultValue("false")); }
Example #16
Source File: AkkaScalaClientCodegen.java From TypeScript-Microservices with MIT License | 4 votes |
public AkkaScalaClientCodegen() { super(); outputFolder = "generated-code/scala"; modelTemplateFiles.put("model.mustache", ".scala"); apiTemplateFiles.put("api.mustache", ".scala"); embeddedTemplateDir = templateDir = "akka-scala"; apiPackage = mainPackage + ".api"; modelPackage = mainPackage + ".model"; invokerPackage = mainPackage + ".core"; setReservedWordsLowerCase( Arrays.asList( "abstract", "case", "catch", "class", "def", "do", "else", "extends", "false", "final", "finally", "for", "forSome", "if", "implicit", "import", "lazy", "match", "new", "null", "object", "override", "package", "private", "protected", "return", "sealed", "super", "this", "throw", "trait", "try", "true", "type", "val", "var", "while", "with", "yield") ); additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); additionalProperties.put(CodegenConstants.GROUP_ID, groupId); additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId); additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion); additionalProperties.put("configKey", configKey); additionalProperties.put("configKeyPath", configKeyPath); additionalProperties.put("defaultTimeout", defaultTimeoutInMs); if (renderJavadoc) { additionalProperties.put("javadocRenderer", new JavadocLambda()); } additionalProperties.put("fnCapitalize", new CapitalizeLambda()); additionalProperties.put("fnCamelize", new CamelizeLambda(false)); additionalProperties.put("fnEnumEntry", new EnumEntryLambda()); additionalProperties.put("onlyOneSuccess", onlyOneSuccess); supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")); supportingFiles.add(new SupportingFile("build.sbt.mustache", "", "build.sbt")); supportingFiles.add(new SupportingFile("reference.mustache", resourcesFolder, "reference.conf")); final String invokerFolder = (sourceFolder + File.separator + invokerPackage).replace(".", File.separator); supportingFiles.add(new SupportingFile("apiRequest.mustache", invokerFolder, "ApiRequest.scala")); supportingFiles.add(new SupportingFile("apiInvoker.mustache", invokerFolder, "ApiInvoker.scala")); supportingFiles.add(new SupportingFile("requests.mustache", invokerFolder, "requests.scala")); supportingFiles.add(new SupportingFile("apiSettings.mustache", invokerFolder, "ApiSettings.scala")); final String apiFolder = (sourceFolder + File.separator + apiPackage).replace(".", File.separator); supportingFiles.add(new SupportingFile("enumsSerializers.mustache", apiFolder, "EnumsSerializers.scala")); importMapping.remove("Seq"); importMapping.remove("List"); importMapping.remove("Set"); importMapping.remove("Map"); importMapping.put("DateTime", "org.joda.time.DateTime"); typeMapping = new HashMap<String, String>(); typeMapping.put("array", "Seq"); typeMapping.put("set", "Set"); typeMapping.put("boolean", "Boolean"); typeMapping.put("string", "String"); typeMapping.put("int", "Int"); typeMapping.put("integer", "Int"); typeMapping.put("long", "Long"); typeMapping.put("float", "Float"); typeMapping.put("byte", "Byte"); typeMapping.put("short", "Short"); typeMapping.put("char", "Char"); typeMapping.put("long", "Long"); typeMapping.put("double", "Double"); typeMapping.put("object", "Any"); typeMapping.put("file", "File"); typeMapping.put("number", "Double"); instantiationTypes.put("array", "ListBuffer"); instantiationTypes.put("map", "Map"); }
Example #17
Source File: RestbedCodegen.java From TypeScript-Microservices with MIT License | 4 votes |
public RestbedCodegen() { super(); apiPackage = "io.swagger.server.api"; modelPackage = "io.swagger.server.model"; modelTemplateFiles.put("model-header.mustache", ".h"); modelTemplateFiles.put("model-source.mustache", ".cpp"); apiTemplateFiles.put("api-header.mustache", ".h"); apiTemplateFiles.put("api-source.mustache", ".cpp"); embeddedTemplateDir = templateDir = "restbed"; cliOptions.clear(); // CLI options addOption(CodegenConstants.MODEL_PACKAGE, "C++ namespace for models (convention: name.space.model).", this.modelPackage); addOption(CodegenConstants.API_PACKAGE, "C++ namespace for apis (convention: name.space.api).", this.apiPackage); addOption(CodegenConstants.PACKAGE_VERSION, "C++ package version.", this.packageVersion); addOption(DECLSPEC, "C++ preprocessor to place before the class name for handling dllexport/dllimport.", this.declspec); addOption(DEFAULT_INCLUDE, "The default include statement that should be placed in all headers for including things like the declspec (convention: #include \"Commons.h\" ", this.defaultInclude); supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); languageSpecificPrimitives = new HashSet<String>( Arrays.asList("int", "char", "bool", "long", "float", "double", "int32_t", "int64_t")); typeMapping = new HashMap<String, String>(); typeMapping.put("date", "std::string"); typeMapping.put("DateTime", "std::string"); typeMapping.put("string", "std::string"); typeMapping.put("integer", "int32_t"); typeMapping.put("long", "int64_t"); typeMapping.put("boolean", "bool"); typeMapping.put("array", "std::vector"); typeMapping.put("map", "std::map"); typeMapping.put("file", "std::string"); typeMapping.put("object", "Object"); typeMapping.put("binary", "restbed::Bytes"); typeMapping.put("number", "double"); typeMapping.put("UUID", "std::string"); super.importMapping = new HashMap<String, String>(); importMapping.put("std::vector", "#include <vector>"); importMapping.put("std::map", "#include <map>"); importMapping.put("std::string", "#include <string>"); importMapping.put("Object", "#include \"Object.h\""); importMapping.put("restbed::Bytes", "#include <corvusoft/restbed/byte.hpp>"); }
Example #18
Source File: EiffelClientCodegen.java From TypeScript-Microservices with MIT License | 4 votes |
@Override public void processOpts() { super.processOpts(); if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) { setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME)); } else { setPackageName("swagger"); } if (additionalProperties.containsKey(CodegenConstants.PACKAGE_VERSION)) { setPackageVersion((String) additionalProperties.get(CodegenConstants.PACKAGE_VERSION)); } else { setPackageVersion("1.0.0"); } additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName); additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion); additionalProperties.put("uuid", uuid.toString()); additionalProperties.put("uuidTest", uuidTest.toString()); additionalProperties.put("libraryTarget", libraryTarget); additionalProperties.put("apiDocPath", apiDocPath); additionalProperties.put("modelDocPath", modelDocPath); modelPackage = packageName; apiPackage = packageName; final String authFolder = ("src/framework/auth"); final String serializerFolder = ("src/framework/serialization"); supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); supportingFiles.add(new SupportingFile("travis.mustache", "", ".travis.yml")); supportingFiles.add(new SupportingFile("ecf.mustache", "", "api_client.ecf")); supportingFiles.add(new SupportingFile("test/ecf_test.mustache", "test", "api_test.ecf")); supportingFiles.add(new SupportingFile("test/application.mustache", "test", "application.e")); supportingFiles.add(new SupportingFile("api_client.mustache", "src", "api_client.e")); supportingFiles.add(new SupportingFile("framework/api_i.mustache", "src/framework", "api_i.e")); supportingFiles.add( new SupportingFile("framework/api_client_request.mustache", "src/framework", "api_client_request.e")); supportingFiles.add( new SupportingFile("framework/api_client_response.mustache", "src/framework", "api_client_response.e")); supportingFiles.add(new SupportingFile("framework/api_error.mustache", "src/framework", "api_error.e")); supportingFiles.add(new SupportingFile("framework/configuration.mustache", "src/framework", "configuration.e")); supportingFiles .add(new SupportingFile("framework/auth/authentication.mustache", authFolder, "authentication.e")); supportingFiles.add(new SupportingFile("framework/auth/api_key_auth.mustache", authFolder, "api_key_auth.e")); supportingFiles .add(new SupportingFile("framework/auth/http_basic_auth.mustache", authFolder, "http_basic_auth.e")); supportingFiles.add(new SupportingFile("framework/auth/oauth.mustache", authFolder, "oauth.e")); supportingFiles.add(new SupportingFile("framework/serialization/api_deserializer.mustache", serializerFolder, "api_deserializer.e")); supportingFiles.add(new SupportingFile("framework/serialization/api_json_deserializer.mustache", serializerFolder, "api_json_deserializer.e")); supportingFiles.add(new SupportingFile("framework/serialization/api_json_serializer.mustache", serializerFolder, "api_json_serializer.e")); supportingFiles.add(new SupportingFile("framework/serialization/api_serializer.mustache", serializerFolder, "api_serializer.e")); supportingFiles.add(new SupportingFile("framework/serialization/json_basic_reflector_deserializer.mustache", serializerFolder, "json_basic_reflector_deserializer.e")); supportingFiles.add(new SupportingFile("framework/serialization/json_type_utilities_ext.mustache", serializerFolder, "json_type_utilities_ext.e")); }
Example #19
Source File: StaticDocCodegen.java From TypeScript-Microservices with MIT License | 4 votes |
public StaticDocCodegen() { super(); // clear import mapping (from default generator) as this generator does not use it // at the moment importMapping.clear(); outputFolder = "docs"; modelTemplateFiles.put("model.mustache", ".html"); apiTemplateFiles.put("operation.mustache", ".html"); embeddedTemplateDir = templateDir = "swagger-static"; cliOptions.add(new CliOption(CodegenConstants.INVOKER_PACKAGE, CodegenConstants.INVOKER_PACKAGE_DESC)); cliOptions.add(new CliOption(CodegenConstants.GROUP_ID, CodegenConstants.GROUP_ID_DESC)); cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_ID, CodegenConstants.ARTIFACT_ID_DESC)); cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_VERSION, CodegenConstants.ARTIFACT_VERSION_DESC)); additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); additionalProperties.put(CodegenConstants.GROUP_ID, groupId); additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId); additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion); supportingFiles.add(new SupportingFile("package.mustache", "", "package.json")); supportingFiles.add(new SupportingFile("main.mustache", "", "main.js")); supportingFiles.add(new SupportingFile("assets/css/bootstrap-responsive.css", outputFolder + "/assets/css", "bootstrap-responsive.css")); supportingFiles.add(new SupportingFile("assets/css/bootstrap.css", outputFolder + "/assets/css", "bootstrap.css")); supportingFiles.add(new SupportingFile("assets/css/style.css", outputFolder + "/assets/css", "style.css")); supportingFiles.add(new SupportingFile("assets/images/logo.png", outputFolder + "/assets/images", "logo.png")); supportingFiles.add(new SupportingFile("assets/js/bootstrap.js", outputFolder + "/assets/js", "bootstrap.js")); supportingFiles.add(new SupportingFile("assets/js/jquery-1.8.3.min.js", outputFolder + "/assets/js", "jquery-1.8.3.min.js")); supportingFiles.add(new SupportingFile("assets/js/main.js", outputFolder + "/assets/js", "main.js")); supportingFiles.add(new SupportingFile("index.mustache", outputFolder, "index.html")); instantiationTypes.put("array", "ArrayList"); instantiationTypes.put("map", "HashMap"); }
Example #20
Source File: FlashClientCodegen.java From TypeScript-Microservices with MIT License | 4 votes |
@Override public void processOpts() { super.processOpts(); if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) { this.setInvokerPackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE)); } else { //not set, use default to be passed to template additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); } if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)) { this.setSourceFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER)); } if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) { setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME)); apiPackage = packageName + ".client.api"; modelPackage = packageName + ".client.model"; } else { setPackageName("io.swagger"); } if (additionalProperties.containsKey(CodegenConstants.PACKAGE_VERSION)) { setPackageVersion((String) additionalProperties.get(CodegenConstants.PACKAGE_VERSION)); } else { setPackageVersion("1.0.0"); } additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName); additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion); //modelPackage = invokerPackage + File.separatorChar + "client" + File.separatorChar + "model"; //apiPackage = invokerPackage + File.separatorChar + "client" + File.separatorChar + "api"; final String invokerFolder = (sourceFolder + File.separator + "src/" + invokerPackage + File.separator).replace(".", File.separator).replace('.', File.separatorChar); supportingFiles.add(new SupportingFile("ApiInvoker.as", invokerFolder + "common", "ApiInvoker.as")); supportingFiles.add(new SupportingFile("ApiUrlHelper.as", invokerFolder + "common", "ApiUrlHelper.as")); supportingFiles.add(new SupportingFile("ApiUserCredentials.as", invokerFolder + "common", "ApiUserCredentials.as")); supportingFiles.add(new SupportingFile("ListWrapper.as", invokerFolder + "common", "ListWrapper.as")); supportingFiles.add(new SupportingFile("SwaggerApi.as", invokerFolder + "common", "SwaggerApi.as")); supportingFiles.add(new SupportingFile("XMLWriter.as", invokerFolder + "common", "XMLWriter.as")); supportingFiles.add(new SupportingFile("ApiError.as", invokerFolder + "exception", "ApiError.as")); supportingFiles.add(new SupportingFile("ApiErrorCodes.as", invokerFolder + "exception", "ApiErrorCodes.as")); supportingFiles.add(new SupportingFile("ApiClientEvent.as", invokerFolder + "event", "ApiClientEvent.as")); supportingFiles.add(new SupportingFile("Response.as", invokerFolder + "event", "Response.as")); supportingFiles.add(new SupportingFile("build.properties", sourceFolder, "build.properties")); supportingFiles.add(new SupportingFile("build.xml", sourceFolder, "build.xml")); supportingFiles.add(new SupportingFile("README.txt", sourceFolder, "README.txt")); //supportingFiles.add(new SupportingFile("AirExecutorApp-app.xml", sourceFolder + File.separatorChar // + "bin", "AirExecutorApp-app.xml")); supportingFiles.add(new SupportingFile("ASAXB-0.1.1.swc", sourceFolder + File.separatorChar + "lib", "ASAXB-0.1.1.swc")); supportingFiles.add(new SupportingFile("as3corelib.swc", sourceFolder + File.separatorChar + "lib", "as3corelib.swc")); supportingFiles.add(new SupportingFile("flexunit-4.1.0_RC2-28-flex_3.5.0.12683.swc", sourceFolder + File.separator + "lib" + File.separator + "ext", "flexunit-4.1.0_RC2-28-flex_3.5.0.12683.swc")); supportingFiles.add(new SupportingFile("flexunit-aircilistener-4.1.0_RC2-28-3.5.0.12683.swc", sourceFolder + File.separator + "lib" + File.separator + "ext", "flexunit-aircilistener-4.1.0_RC2-28-3.5.0.12683.swc")); supportingFiles.add(new SupportingFile("flexunit-cilistener-4.1.0_RC2-28-3.5.0.12683.swc", sourceFolder + File.separator + "lib" + File.separator + "ext", "flexunit-cilistener-4.1.0_RC2-28-3.5.0.12683.swc")); supportingFiles.add(new SupportingFile("flexunit-core-flex-4.0.0.2-sdk3.5.0.12683.swc", sourceFolder + File.separator + "lib" + File.separator + "ext", "flexunit-core-flex-4.0.0.2-sdk3.5.0.12683.swc")); supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); }
Example #21
Source File: FlashClientCodegen.java From TypeScript-Microservices with MIT License | 4 votes |
public FlashClientCodegen() { super(); modelPackage = "io.swagger.client.model"; apiPackage = "io.swagger.client.api"; outputFolder = "generated-code" + File.separatorChar + "flash"; modelTemplateFiles.put("model.mustache", ".as"); modelTemplateFiles.put("modelList.mustache", "List.as"); apiTemplateFiles.put("api.mustache", ".as"); embeddedTemplateDir = templateDir = "flash"; languageSpecificPrimitives.clear(); languageSpecificPrimitives.add("Number"); languageSpecificPrimitives.add("Boolean"); languageSpecificPrimitives.add("String"); languageSpecificPrimitives.add("Date"); languageSpecificPrimitives.add("Array"); languageSpecificPrimitives.add("Dictionary"); typeMapping.clear(); typeMapping.put("integer", "Number"); typeMapping.put("float", "Number"); typeMapping.put("long", "Number"); typeMapping.put("double", "Number"); typeMapping.put("array", "Array"); typeMapping.put("map", "Dictionary"); typeMapping.put("boolean", "Boolean"); typeMapping.put("string", "String"); typeMapping.put("date", "Date"); typeMapping.put("DateTime", "Date"); typeMapping.put("object", "Object"); typeMapping.put("file", "File"); typeMapping.put("UUID", "String"); //TODO binary should be mapped to byte array // mapped to String as a workaround typeMapping.put("binary", "String"); importMapping = new HashMap<String, String>(); importMapping.put("File", "flash.filesystem.File"); // from setReservedWordsLowerCase(Arrays.asList("add", "for", "lt", "tellTarget", "and", "function", "ne", "this", "break", "ge", "new", "typeof", "continue", "gt", "not", "var", "delete", "if", "on", "void", "do", "ifFrameLoaded", "onClipEvent", "while", "else", "in", "or", "with", "eq", "le", "return")); cliOptions.clear(); cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "flash package name (convention:" + " package.name)").defaultValue("io.swagger")); cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "flash package version") .defaultValue("1.0.0")); cliOptions.add(new CliOption(CodegenConstants.INVOKER_PACKAGE, CodegenConstants.INVOKER_PACKAGE_DESC)); cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, "source folder for generated " + "code. e.g. flash")); }
Example #22
Source File: CodegenConfigurator.java From TypeScript-Microservices with MIT License | 4 votes |
public ClientOptInput toClientOptInput() { Validate.notEmpty(lang, "language must be specified"); Validate.notEmpty(inputSpec, "input spec must be specified"); setVerboseFlags(); setSystemProperties(); CodegenConfig config = CodegenConfigLoader.forName(lang); config.setInputSpec(inputSpec); config.setOutputDir(outputDir); config.setSkipOverwrite(skipOverwrite); config.setIgnoreFilePathOverride(ignoreFileOverride); config.setRemoveOperationIdPrefix(removeOperationIdPrefix); config.instantiationTypes().putAll(instantiationTypes); config.typeMapping().putAll(typeMappings); config.importMapping().putAll(importMappings); config.languageSpecificPrimitives().addAll(languageSpecificPrimitives); config.reservedWordsMappings().putAll(reservedWordMappings); checkAndSetAdditionalProperty(apiPackage, CodegenConstants.API_PACKAGE); checkAndSetAdditionalProperty(modelPackage, CodegenConstants.MODEL_PACKAGE); checkAndSetAdditionalProperty(invokerPackage, CodegenConstants.INVOKER_PACKAGE); checkAndSetAdditionalProperty(groupId, CodegenConstants.GROUP_ID); checkAndSetAdditionalProperty(artifactId, CodegenConstants.ARTIFACT_ID); checkAndSetAdditionalProperty(artifactVersion, CodegenConstants.ARTIFACT_VERSION); checkAndSetAdditionalProperty(templateDir, toAbsolutePathStr(templateDir), CodegenConstants.TEMPLATE_DIR); checkAndSetAdditionalProperty(modelNamePrefix, CodegenConstants.MODEL_NAME_PREFIX); checkAndSetAdditionalProperty(modelNameSuffix, CodegenConstants.MODEL_NAME_SUFFIX); checkAndSetAdditionalProperty(gitUserId, CodegenConstants.GIT_USER_ID); checkAndSetAdditionalProperty(gitRepoId, CodegenConstants.GIT_REPO_ID); checkAndSetAdditionalProperty(releaseNote, CodegenConstants.RELEASE_NOTE); checkAndSetAdditionalProperty(httpUserAgent, CodegenConstants.HTTP_USER_AGENT); handleDynamicProperties(config); if (isNotEmpty(library)) { config.setLibrary(library); } config.additionalProperties().putAll(additionalProperties); ClientOptInput input = new ClientOptInput() .config(config); final List<AuthorizationValue> authorizationValues = AuthParser.parse(auth); Swagger swagger = new SwaggerParser().read(inputSpec, authorizationValues, true); input.opts(new ClientOpts()) .swagger(swagger); return input; }
Example #23
Source File: SilexServerCodegen.java From TypeScript-Microservices with MIT License | 4 votes |
public SilexServerCodegen() { super(); invokerPackage = camelize("SwaggerServer"); String packagePath = "SwaggerServer"; modelPackage = packagePath + "/lib/models"; apiPackage = packagePath + "/lib"; outputFolder = "generated-code/php-silex"; // no model, api files modelTemplateFiles.clear(); apiTemplateFiles.clear(); embeddedTemplateDir = templateDir = "php-silex"; setReservedWordsLowerCase( Arrays.asList( "__halt_compiler", "abstract", "and", "array", "as", "break", "callable", "case", "catch", "class", "clone", "const", "continue", "declare", "default", "die", "do", "echo", "else", "elseif", "empty", "enddeclare", "endfor", "endforeach", "endif", "endswitch", "endwhile", "eval", "exit", "extends", "final", "for", "foreach", "function", "global", "goto", "if", "implements", "include", "include_once", "instanceof", "insteadof", "interface", "isset", "list", "namespace", "new", "or", "print", "private", "protected", "public", "require", "require_once", "return", "static", "switch", "throw", "trait", "try", "unset", "use", "var", "while", "xor") ); additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); additionalProperties.put(CodegenConstants.GROUP_ID, groupId); additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId); additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion); // ref: http://php.net/manual/en/language.types.intro.php languageSpecificPrimitives = new HashSet<String>( Arrays.asList( "boolean", "int", "integer", "double", "float", "string", "object", "DateTime", "mixed", "number") ); instantiationTypes.put("array", "array"); instantiationTypes.put("map", "map"); // ref: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types typeMapping = new HashMap<String, String>(); typeMapping.put("integer", "int"); typeMapping.put("long", "int"); typeMapping.put("float", "float"); typeMapping.put("double", "double"); typeMapping.put("string", "string"); typeMapping.put("byte", "int"); typeMapping.put("boolean", "boolean"); typeMapping.put("date", "DateTime"); typeMapping.put("datetime", "DateTime"); typeMapping.put("file", "string"); typeMapping.put("map", "map"); typeMapping.put("array", "array"); typeMapping.put("list", "array"); typeMapping.put("object", "object"); //TODO binary should be mapped to byte array // mapped to String as a workaround typeMapping.put("binary", "string"); supportingFiles.add(new SupportingFile("README.mustache", packagePath.replace('/', File.separatorChar), "README.md")); supportingFiles.add(new SupportingFile("composer.json", packagePath.replace('/', File.separatorChar), "composer.json")); supportingFiles.add(new SupportingFile("index.mustache", packagePath.replace('/', File.separatorChar), "index.php")); supportingFiles.add(new SupportingFile(".htaccess", packagePath.replace('/', File.separatorChar), ".htaccess")); }
Example #24
Source File: JavascriptClientCodegen.java From TypeScript-Microservices with MIT License | 4 votes |
@Override public void preprocessSwagger(Swagger swagger) { super.preprocessSwagger(swagger); if (swagger.getInfo() != null) { Info info = swagger.getInfo(); if (StringUtils.isBlank(projectName) && info.getTitle() != null) { // when projectName is not specified, generate it from info.title projectName = sanitizeName(dashize(info.getTitle())); } if (StringUtils.isBlank(projectVersion)) { // when projectVersion is not specified, use info.version projectVersion = escapeUnsafeCharacters(escapeQuotationMark(info.getVersion())); } if (projectDescription == null) { // when projectDescription is not specified, use info.description projectDescription = sanitizeName(info.getDescription()); } // when licenceName is not specified, use info.license if (additionalProperties.get(CodegenConstants.LICENSE_NAME) == null && info.getLicense() != null) { License license = info.getLicense(); licenseName = license.getName(); } } // default values if (StringUtils.isBlank(projectName)) { projectName = "swagger-js-client"; } if (StringUtils.isBlank(moduleName)) { moduleName = camelize(underscore(projectName)); } if (StringUtils.isBlank(projectVersion)) { projectVersion = "1.0.0"; } if (projectDescription == null) { projectDescription = "Client library of " + projectName; } if (StringUtils.isBlank(licenseName)) { licenseName = "Unlicense"; } additionalProperties.put(PROJECT_NAME, projectName); additionalProperties.put(MODULE_NAME, moduleName); additionalProperties.put(PROJECT_DESCRIPTION, escapeText(projectDescription)); additionalProperties.put(PROJECT_VERSION, projectVersion); additionalProperties.put(CodegenConstants.LICENSE_NAME, licenseName); additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage); additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); additionalProperties.put(CodegenConstants.LOCAL_VARIABLE_PREFIX, localVariablePrefix); additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage); additionalProperties.put(CodegenConstants.SOURCE_FOLDER, sourceFolder); additionalProperties.put(USE_PROMISES, usePromises); additionalProperties.put(USE_INHERITANCE, supportsInheritance); additionalProperties.put(EMIT_MODEL_METHODS, emitModelMethods); additionalProperties.put(EMIT_JS_DOC, emitJSDoc); additionalProperties.put(USE_ES6, useES6); // make api and model doc path available in mustache template additionalProperties.put("apiDocPath", apiDocPath); additionalProperties.put("modelDocPath", modelDocPath); String[][] supportingTemplateFiles = JAVASCRIPT_SUPPORTING_FILES; if (useES6) { supportingTemplateFiles = JAVASCRIPT_ES6_SUPPORTING_FILES; } for (String[] supportingTemplateFile :supportingTemplateFiles) { supportingFiles.add(new SupportingFile(supportingTemplateFile[0], "", supportingTemplateFile[1])); } }
Example #25
Source File: JavascriptClientCodegen.java From TypeScript-Microservices with MIT License | 4 votes |
@Override public void processOpts() { if (additionalProperties.containsKey(USE_ES6)) { setUseES6(convertPropertyToBooleanAndWriteBack(USE_ES6)); } else { setUseES6(false); // default to ES5 } super.processOpts(); if (additionalProperties.containsKey(PROJECT_NAME)) { setProjectName(((String) additionalProperties.get(PROJECT_NAME))); } if (additionalProperties.containsKey(MODULE_NAME)) { setModuleName(((String) additionalProperties.get(MODULE_NAME))); } if (additionalProperties.containsKey(PROJECT_DESCRIPTION)) { setProjectDescription(((String) additionalProperties.get(PROJECT_DESCRIPTION))); } if (additionalProperties.containsKey(PROJECT_VERSION)) { setProjectVersion(((String) additionalProperties.get(PROJECT_VERSION))); } if (additionalProperties.containsKey(CodegenConstants.LICENSE_NAME)) { setLicenseName(((String) additionalProperties.get(CodegenConstants.LICENSE_NAME))); } if (additionalProperties.containsKey(CodegenConstants.LOCAL_VARIABLE_PREFIX)) { setLocalVariablePrefix((String) additionalProperties.get(CodegenConstants.LOCAL_VARIABLE_PREFIX)); } if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)) { setSourceFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER)); } if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) { setInvokerPackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE)); } if (additionalProperties.containsKey(USE_PROMISES)) { setUsePromises(convertPropertyToBooleanAndWriteBack(USE_PROMISES)); } if (additionalProperties.containsKey(USE_INHERITANCE)) { setUseInheritance(convertPropertyToBooleanAndWriteBack(USE_INHERITANCE)); } else { supportsInheritance = true; supportsMixins = true; } if (additionalProperties.containsKey(EMIT_MODEL_METHODS)) { setEmitModelMethods(convertPropertyToBooleanAndWriteBack(EMIT_MODEL_METHODS)); } if (additionalProperties.containsKey(EMIT_JS_DOC)) { setEmitJSDoc(convertPropertyToBooleanAndWriteBack(EMIT_JS_DOC)); } }
Example #26
Source File: IoCCodeGenerator.java From yang2swagger with Eclipse Public License 1.0 | 4 votes |
public static void main(String[] args) throws Exception { Guice.createInjector(new GeneratorInjector()); IoCSwaggerGenerator generator; if(args.length == 1) { // prepare a default generator for a given directory with YANG modules and accept all of them for path // generation generator = IoCGeneratorHelper.getGenerator(new File(args[0]),m -> true); } else { // prepare a default generator for all YANG modules and from classpath and accept only these which name // starts from 'tapi' generator = IoCGeneratorHelper.getGenerator(m -> m.getName().startsWith("Tapi")); } generator.tagGenerator(new SegmentTagGenerator()); // -------- configure path generator --------------- // for data tree generate only GET operations // generator.pathHandler(new PathHandlerBuilder().withoutFullCrud()); // for data tree generate full CRUD (depending on config flag in yang modules Swagger swagger = generator.generate(); JerseyServerCodegen codegenConfig = new JerseyServerCodegen(); // referencing handler for x-path annotation // codegenConfig.addAnnotation("propAnnotation", "x-path", v -> // "@com.mrv.provision.di.rest.jersey.metadata.Leafref(\"" + v + "\")" // ); ClientOpts clientOpts = new ClientOpts(); Path target = Files.createTempDirectory("generated"); codegenConfig.additionalProperties().put(CodegenConstants.API_PACKAGE, "com.mrv.provision.di.rest.jersey.tapi.api"); codegenConfig.additionalProperties().put(CodegenConstants.MODEL_PACKAGE, "com.mrv.provision.di.rest.jersey.tapi.model"); codegenConfig.setOutputDir(target.toString()); // write swagger.yaml to the target ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.writeValue(new FileWriter(new File(target.toFile(), "tapi.yaml")), swagger); ClientOptInput opts = new ClientOptInput().opts(clientOpts).swagger(swagger).config(codegenConfig); new DefaultGenerator() .opts(opts) .generate(); }
Example #27
Source File: AbstractScalaCodegen.java From TypeScript-Microservices with MIT License | 4 votes |
public AbstractScalaCodegen() { super(); languageSpecificPrimitives.addAll(Arrays.asList( "String", "boolean", "Boolean", "Double", "Int", "Long", "Float", "Object", "Any", "List", "Seq", "Map", "Array")); reservedWords.addAll(Arrays.asList( "abstract", "case", "catch", "class", "def", "do", "else", "extends", "false", "final", "finally", "for", "forSome", "if", "implicit", "import", "lazy", "match", "new", "null", "object", "override", "package", "private", "protected", "return", "sealed", "super", "this", "throw", "trait", "try", "true", "type", "val", "var", "while", "with", "yield" )); cliOptions.add(new CliOption(CodegenConstants.MODEL_PACKAGE, CodegenConstants.MODEL_PACKAGE_DESC)); cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC)); cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, CodegenConstants.SOURCE_FOLDER_DESC)); }
Example #28
Source File: CppRestClientCodegen.java From TypeScript-Microservices with MIT License | 4 votes |
public CppRestClientCodegen() { super(); apiPackage = "io.swagger.client.api"; modelPackage = "io.swagger.client.model"; modelTemplateFiles.put("model-header.mustache", ".h"); modelTemplateFiles.put("model-source.mustache", ".cpp"); apiTemplateFiles.put("api-header.mustache", ".h"); apiTemplateFiles.put("api-source.mustache", ".cpp"); embeddedTemplateDir = templateDir = "cpprest"; cliOptions.clear(); // CLI options addOption(CodegenConstants.MODEL_PACKAGE, "C++ namespace for models (convention: name.space.model).", this.modelPackage); addOption(CodegenConstants.API_PACKAGE, "C++ namespace for apis (convention: name.space.api).", this.apiPackage); addOption(CodegenConstants.PACKAGE_VERSION, "C++ package version.", this.packageVersion); addOption(DECLSPEC, "C++ preprocessor to place before the class name for handling dllexport/dllimport.", this.declspec); addOption(DEFAULT_INCLUDE, "The default include statement that should be placed in all headers for including things like the declspec (convention: #include \"Commons.h\" ", this.defaultInclude); supportingFiles.add(new SupportingFile("modelbase-header.mustache", "", "ModelBase.h")); supportingFiles.add(new SupportingFile("modelbase-source.mustache", "", "ModelBase.cpp")); supportingFiles.add(new SupportingFile("object-header.mustache", "", "Object.h")); supportingFiles.add(new SupportingFile("object-source.mustache", "", "Object.cpp")); supportingFiles.add(new SupportingFile("apiclient-header.mustache", "", "ApiClient.h")); supportingFiles.add(new SupportingFile("apiclient-source.mustache", "", "ApiClient.cpp")); supportingFiles.add(new SupportingFile("apiconfiguration-header.mustache", "", "ApiConfiguration.h")); supportingFiles.add(new SupportingFile("apiconfiguration-source.mustache", "", "ApiConfiguration.cpp")); supportingFiles.add(new SupportingFile("apiexception-header.mustache", "", "ApiException.h")); supportingFiles.add(new SupportingFile("apiexception-source.mustache", "", "ApiException.cpp")); supportingFiles.add(new SupportingFile("ihttpbody-header.mustache", "", "IHttpBody.h")); supportingFiles.add(new SupportingFile("jsonbody-header.mustache", "", "JsonBody.h")); supportingFiles.add(new SupportingFile("jsonbody-source.mustache", "", "JsonBody.cpp")); supportingFiles.add(new SupportingFile("httpcontent-header.mustache", "", "HttpContent.h")); supportingFiles.add(new SupportingFile("httpcontent-source.mustache", "", "HttpContent.cpp")); supportingFiles.add(new SupportingFile("multipart-header.mustache", "", "MultipartFormData.h")); supportingFiles.add(new SupportingFile("multipart-source.mustache", "", "MultipartFormData.cpp")); supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); supportingFiles.add(new SupportingFile("cmake-lists.mustache", "", "CMakeLists.txt")); languageSpecificPrimitives = new HashSet<String>( Arrays.asList("int", "char", "bool", "long", "float", "double", "int32_t", "int64_t")); typeMapping = new HashMap<String, String>(); typeMapping.put("date", "utility::datetime"); typeMapping.put("DateTime", "utility::datetime"); typeMapping.put("string", "utility::string_t"); typeMapping.put("integer", "int32_t"); typeMapping.put("long", "int64_t"); typeMapping.put("boolean", "bool"); typeMapping.put("array", "std::vector"); typeMapping.put("map", "std::map"); typeMapping.put("file", "HttpContent"); typeMapping.put("object", "Object"); typeMapping.put("binary", "std::string"); typeMapping.put("number", "double"); typeMapping.put("UUID", "utility::string_t"); super.importMapping = new HashMap<String, String>(); importMapping.put("std::vector", "#include <vector>"); importMapping.put("std::map", "#include <map>"); importMapping.put("std::string", "#include <string>"); importMapping.put("HttpContent", "#include \"HttpContent.h\""); importMapping.put("Object", "#include \"Object.h\""); importMapping.put("utility::string_t", "#include <cpprest/details/basic_types.h>"); importMapping.put("utility::datetime", "#include <cpprest/details/basic_types.h>"); }
Example #29
Source File: AndroidClientCodegen.java From TypeScript-Microservices with MIT License | 4 votes |
@Override public void processOpts() { super.processOpts(); if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) { this.setInvokerPackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE)); this.setRequestPackage(invokerPackage + ".request"); this.setAuthPackage(invokerPackage + ".auth"); } else { //not set, use default to be passed to template additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); additionalProperties.put("requestPackage", requestPackage); additionalProperties.put("authPackage", authPackage); } if (!additionalProperties.containsKey(CodegenConstants.MODEL_PACKAGE)) { additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage); } if (!additionalProperties.containsKey(CodegenConstants.API_PACKAGE)) { additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage); } if (additionalProperties.containsKey(CodegenConstants.GROUP_ID)) { this.setGroupId((String) additionalProperties.get(CodegenConstants.GROUP_ID)); } else { //not set, use to be passed to template additionalProperties.put(CodegenConstants.GROUP_ID, groupId); } if (additionalProperties.containsKey(CodegenConstants.ARTIFACT_ID)) { this.setArtifactId((String) additionalProperties.get(CodegenConstants.ARTIFACT_ID)); } else { //not set, use to be passed to template additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId); } if (additionalProperties.containsKey(CodegenConstants.ARTIFACT_VERSION)) { this.setArtifactVersion((String) additionalProperties.get(CodegenConstants.ARTIFACT_VERSION)); } else { //not set, use to be passed to template additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion); } if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)) { this.setSourceFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER)); } if (additionalProperties.containsKey(USE_ANDROID_MAVEN_GRADLE_PLUGIN)) { this.setUseAndroidMavenGradlePlugin(Boolean.valueOf((String) additionalProperties .get(USE_ANDROID_MAVEN_GRADLE_PLUGIN))); } else { additionalProperties.put(USE_ANDROID_MAVEN_GRADLE_PLUGIN, useAndroidMavenGradlePlugin); } if (additionalProperties.containsKey(ANDROID_GRADLE_VERSION)) { this.setAndroidGradleVersion((String) additionalProperties.get(ANDROID_GRADLE_VERSION)); } if (additionalProperties.containsKey(ANDROID_SDK_VERSION)) { this.setAndroidSdkVersion((String) additionalProperties.get(ANDROID_SDK_VERSION)); } if (additionalProperties.containsKey(ANDROID_BUILD_TOOLS_VERSION)) { this.setAndroidBuildToolsVersion((String) additionalProperties.get(ANDROID_BUILD_TOOLS_VERSION)); } if (additionalProperties.containsKey(CodegenConstants.LIBRARY)) { this.setLibrary((String) additionalProperties.get(CodegenConstants.LIBRARY)); } if (additionalProperties.containsKey(CodegenConstants.SERIALIZABLE_MODEL)) { this.setSerializableModel(Boolean.valueOf(additionalProperties.get(CodegenConstants.SERIALIZABLE_MODEL).toString())); } // need to put back serializableModel (boolean) into additionalProperties as value in additionalProperties is string additionalProperties.put(CodegenConstants.SERIALIZABLE_MODEL, serializableModel); //make api and model doc path available in mustache template additionalProperties.put( "apiDocPath", apiDocPath ); additionalProperties.put( "modelDocPath", modelDocPath ); if (StringUtils.isEmpty(getLibrary())) { setLibrary("volley"); // set volley as the default library } // determine which file (mustache) to add based on library if ("volley".equals(getLibrary())) { addSupportingFilesForVolley(); } else if ("httpclient".equals(getLibrary())) { addSupportingFilesForHttpClient(); } else { throw new IllegalArgumentException("Invalid 'library' option specified: '" + getLibrary() + "'. Must be 'httpclient' or 'volley' (default)"); } }
Example #30
Source File: ScalatraServerCodegen.java From TypeScript-Microservices with MIT License | 4 votes |
public ScalatraServerCodegen() { super(); outputFolder = "generated-code/scalatra"; modelTemplateFiles.put("model.mustache", ".scala"); apiTemplateFiles.put("api.mustache", ".scala"); embeddedTemplateDir = templateDir = "scalatra"; apiPackage = "io.swagger.server.api"; modelPackage = "io.swagger.server.model"; setReservedWordsLowerCase( Arrays.asList( "abstract", "continue", "for", "new", "switch", "assert", "default", "if", "package", "synchronized", "boolean", "do", "goto", "private", "this", "break", "double", "implements", "protected", "throw", "byte", "else", "import", "public", "throws", "case", "enum", "instanceof", "return", "transient", "catch", "extends", "int", "short", "try", "char", "final", "interface", "static", "void", "class", "finally", "long", "strictfp", "volatile", "const", "float", "native", "super", "while", "type") ); defaultIncludes = new HashSet<String>( Arrays.asList("double", "Int", "Long", "Float", "Double", "char", "float", "String", "boolean", "Boolean", "Double", "Integer", "Long", "Float", "List", "Set", "Map") ); typeMapping.put("integer", "Int"); typeMapping.put("long", "Long"); //TODO binary should be mapped to byte array // mapped to String as a workaround typeMapping.put("binary", "String"); additionalProperties.put("appName", "Swagger Sample"); additionalProperties.put("appDescription", "A sample swagger server"); additionalProperties.put("infoUrl", "http://swagger.io"); additionalProperties.put("infoEmail", "[email protected]"); additionalProperties.put("licenseInfo", "All rights reserved"); additionalProperties.put("licenseUrl", "http://apache.org/licenses/LICENSE-2.0.html"); additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); additionalProperties.put(CodegenConstants.GROUP_ID, groupId); additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId); additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion); supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); supportingFiles.add(new SupportingFile("build.sbt", "", "build.sbt")); supportingFiles.add(new SupportingFile("web.xml", "/src/main/webapp/WEB-INF", "web.xml")); supportingFiles.add(new SupportingFile("logback.xml", "/src/main/resources", "logback.xml")); supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); supportingFiles.add(new SupportingFile("JettyMain.mustache", sourceFolder, "JettyMain.scala")); supportingFiles.add(new SupportingFile("Bootstrap.mustache", sourceFolder, "ScalatraBootstrap.scala")); supportingFiles.add(new SupportingFile("ServletApp.mustache", sourceFolder, "ServletApp.scala")); supportingFiles.add(new SupportingFile("project/build.properties", "project", "build.properties")); supportingFiles.add(new SupportingFile("project/plugins.sbt", "project", "plugins.sbt")); supportingFiles.add(new SupportingFile("sbt", "", "sbt")); instantiationTypes.put("array", "ArrayList"); instantiationTypes.put("map", "HashMap"); importMapping = new HashMap<String, String>(); importMapping.put("BigDecimal", "java.math.BigDecimal"); importMapping.put("UUID", "java.util.UUID"); importMapping.put("File", "java.io.File"); importMapping.put("Date", "java.util.Date"); importMapping.put("Timestamp", "java.sql.Timestamp"); importMapping.put("Map", "java.util.Map"); importMapping.put("HashMap", "java.util.HashMap"); importMapping.put("Array", "java.util.List"); importMapping.put("ArrayList", "java.util.ArrayList"); importMapping.put("DateTime", "org.joda.time.DateTime"); importMapping.put("LocalDateTime", "org.joda.time.LocalDateTime"); importMapping.put("LocalDate", "org.joda.time.LocalDate"); importMapping.put("LocalTime", "org.joda.time.LocalTime"); }