Java Code Examples for io.swagger.codegen.CodegenConstants#LIBRARY
The following examples show how to use
io.swagger.codegen.CodegenConstants#LIBRARY .
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: 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 2
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 3
Source File: AndroidClientCodegen.java From TypeScript-Microservices with MIT License | 4 votes |
public AndroidClientCodegen() { super(); outputFolder = "generated-code/android"; modelTemplateFiles.put("model.mustache", ".java"); apiTemplateFiles.put("api.mustache", ".java"); embeddedTemplateDir = templateDir = "android"; apiPackage = "io.swagger.client.api"; modelPackage = "io.swagger.client.model"; setReservedWordsLowerCase( Arrays.asList( // local variable names used in API methods (endpoints) "localVarPostBody", "localVarPath", "localVarQueryParams", "localVarHeaderParams", "localVarFormParams", "localVarContentTypes", "localVarContentType", "localVarResponse", "localVarBuilder", "authNames", "basePath", "apiInvoker", // due to namespace collusion "Object", // android reserved words "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", "null") ); languageSpecificPrimitives = new HashSet<String>( Arrays.asList( "String", "boolean", "Boolean", "Double", "Integer", "Long", "Float", "byte[]", "Object") ); instantiationTypes.put("array", "ArrayList"); instantiationTypes.put("map", "HashMap"); typeMapping.put("date", "Date"); typeMapping.put("file", "File"); 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.INVOKER_PACKAGE, CodegenConstants.INVOKER_PACKAGE_DESC)); cliOptions.add(new CliOption(CodegenConstants.GROUP_ID, "groupId for use in the generated build.gradle and pom.xml")); cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_ID, "artifactId for use in the generated build.gradle and pom.xml")); cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_VERSION, "artifact version for use in the generated build.gradle and pom.xml")); cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, CodegenConstants.SOURCE_FOLDER_DESC)); cliOptions.add(CliOption.newBoolean(USE_ANDROID_MAVEN_GRADLE_PLUGIN, "A flag to toggle android-maven gradle plugin.") .defaultValue(Boolean.TRUE.toString())); cliOptions.add(new CliOption(ANDROID_GRADLE_VERSION, "gradleVersion version for use in the generated build.gradle")); cliOptions.add(new CliOption(ANDROID_SDK_VERSION, "compileSdkVersion version for use in the generated build.gradle")); cliOptions.add(new CliOption(ANDROID_BUILD_TOOLS_VERSION, "buildToolsVersion version for use in the generated build.gradle")); cliOptions.add(CliOption.newBoolean(CodegenConstants.SERIALIZABLE_MODEL, CodegenConstants.SERIALIZABLE_MODEL_DESC)); supportedLibraries.put("volley", "HTTP client: Volley 1.0.19 (default)"); supportedLibraries.put("httpclient", "HTTP client: Apache HttpClient 4.3.6. JSON processing: Gson 2.3.1. IMPORTANT: Android client using HttpClient is not actively maintained and will be depecreated in the next major release."); CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use"); library.setEnum(supportedLibraries); cliOptions.add(library); }
Example 4
Source File: JavaJAXRSSpecServerCodegen.java From TypeScript-Microservices with MIT License | 4 votes |
public JavaJAXRSSpecServerCodegen() { super(); invokerPackage = "io.swagger.api"; artifactId = "swagger-jaxrs-server"; outputFolder = "generated-code/JavaJaxRS-Spec"; modelTemplateFiles.put("model.mustache", ".java"); apiTemplateFiles.put("api.mustache", ".java"); apiPackage = "io.swagger.api"; modelPackage = "io.swagger.model"; apiTestTemplateFiles.clear(); // TODO: add api test template modelTestTemplateFiles.clear(); // TODO: add model test template // clear model and api doc template as this codegen // does not support auto-generated markdown doc at the moment //TODO: add doc templates modelDocTemplateFiles.remove("model_doc.mustache"); apiDocTemplateFiles.remove("api_doc.mustache"); additionalProperties.put("title", title); typeMapping.put("date", "LocalDate"); importMapping.put("LocalDate", "org.joda.time.LocalDate"); super.embeddedTemplateDir = templateDir = JAXRS_TEMPLATE_DIRECTORY_NAME + File.separator + "spec"; for ( int i = 0; i < cliOptions.size(); i++ ) { if ( CodegenConstants.LIBRARY.equals(cliOptions.get(i).getOpt()) ) { cliOptions.remove(i); break; } } CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use"); library.setDefault(DEFAULT_LIBRARY); Map<String, String> supportedLibraries = new LinkedHashMap<String,String>(); supportedLibraries.put(DEFAULT_LIBRARY, "JAXRS"); library.setEnum(supportedLibraries); cliOptions.add(library); cliOptions.add(CliOption.newBoolean(GENERATE_POM, "Whether to generate pom.xml if the file does not already exist.").defaultValue(String.valueOf(generatePom))); cliOptions.add(CliOption.newBoolean(INTERFACE_ONLY, "Whether to generate only API interface stubs without the server files.").defaultValue(String.valueOf(interfaceOnly))); cliOptions.add(CliOption.newBoolean(RETURN_RESPONSE, "Whether generate API interface should return javax.ws.rs.core.Response instead of a deserialized entity. Only useful if interfaceOnly is true.").defaultValue(String.valueOf(returnResponse))); }