org.openapitools.codegen.SupportingFile Java Examples
The following examples show how to use
org.openapitools.codegen.SupportingFile.
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: KotlinClientCodegen.java From openapi-generator with Apache License 2.0 | 6 votes |
private void addSupportingSerializerAdapters(final String infrastructureFolder) { supportingFiles.add(new SupportingFile("jvm-common/infrastructure/Serializer.kt.mustache", infrastructureFolder, "Serializer.kt")); supportingFiles.add(new SupportingFile("jvm-common/infrastructure/ByteArrayAdapter.kt.mustache", infrastructureFolder, "ByteArrayAdapter.kt")); switch (getSerializationLibrary()) { case moshi: supportingFiles.add(new SupportingFile("jvm-common/infrastructure/UUIDAdapter.kt.mustache", infrastructureFolder, "UUIDAdapter.kt")); supportingFiles.add(new SupportingFile("jvm-common/infrastructure/LocalDateAdapter.kt.mustache", infrastructureFolder, "LocalDateAdapter.kt")); supportingFiles.add(new SupportingFile("jvm-common/infrastructure/LocalDateTimeAdapter.kt.mustache", infrastructureFolder, "LocalDateTimeAdapter.kt")); supportingFiles.add(new SupportingFile("jvm-common/infrastructure/OffsetDateTimeAdapter.kt.mustache", infrastructureFolder, "OffsetDateTimeAdapter.kt")); break; case gson: supportingFiles.add(new SupportingFile("jvm-common/infrastructure/DateAdapter.kt.mustache", infrastructureFolder, "DateAdapter.kt")); supportingFiles.add(new SupportingFile("jvm-common/infrastructure/LocalDateAdapter.kt.mustache", infrastructureFolder, "LocalDateAdapter.kt")); supportingFiles.add(new SupportingFile("jvm-common/infrastructure/LocalDateTimeAdapter.kt.mustache", infrastructureFolder, "LocalDateTimeAdapter.kt")); supportingFiles.add(new SupportingFile("jvm-common/infrastructure/OffsetDateTimeAdapter.kt.mustache", infrastructureFolder, "OffsetDateTimeAdapter.kt")); break; case jackson: //supportingFiles.add(new SupportingFile("jvm-common/infrastructure/DateAdapter.kt.mustache", infrastructureFolder, "DateAdapter.kt")); break; } }
Example #2
Source File: ServiceCombCodegenTest.java From servicecomb-toolkit with Apache License 2.0 | 6 votes |
@Test public void spirngCloudProviderDirectoryStrategy() { SpringCloudProviderDirectoryStrategy providerDirectoryStrategy = new SpringCloudProviderDirectoryStrategy(); Map<String, Object> propertiesMap = new HashMap<>(); propertiesMap.put("artifactId", "provider"); propertiesMap.put("mainClassPackage", "provider"); providerDirectoryStrategy.addCustomProperties(propertiesMap); providerDirectoryStrategy.processSupportingFile(new ArrayList<SupportingFile>()); Assert.assertEquals("provider", providerDirectoryStrategy.providerDirectory()); Assert.assertEquals("provider", providerDirectoryStrategy.modelDirectory()); try { providerDirectoryStrategy.consumerDirectory(); } catch (Exception e) { Assert.assertTrue(e instanceof UnsupportedOperationException); } }
Example #3
Source File: ServiceCombCodegenTest.java From servicecomb-toolkit with Apache License 2.0 | 6 votes |
@Test public void spirngCloudConsumerDirectoryStrategy() { SpringCloudConsumerDirectoryStrategy consumerDirectoryStrategy = new SpringCloudConsumerDirectoryStrategy(); Map<String, Object> propertiesMap = new HashMap<>(); propertiesMap.put("artifactId", "consumer"); propertiesMap.put("mainClassPackage", "consumer"); propertiesMap.put("providerServiceId", "provider"); propertiesMap.put("apiTemplateFiles", new HashMap<String, String>()); consumerDirectoryStrategy.addCustomProperties(propertiesMap); consumerDirectoryStrategy.processSupportingFile(new ArrayList<SupportingFile>()); Assert.assertEquals("consumer", consumerDirectoryStrategy.consumerDirectory()); Assert.assertEquals("consumer", consumerDirectoryStrategy.modelDirectory()); try { consumerDirectoryStrategy.providerDirectory(); } catch (Exception e) { Assert.assertTrue(e instanceof UnsupportedOperationException); } }
Example #4
Source File: OpenAPIGenerator.java From openapi-generator with Apache License 2.0 | 6 votes |
public OpenAPIGenerator() { super(); modifyFeatureSet(features -> features .documentationFeatures(EnumSet.allOf(DocumentationFeature.class)) .dataTypeFeatures(EnumSet.allOf(DataTypeFeature.class)) .wireFormatFeatures(EnumSet.allOf(WireFormatFeature.class)) .securityFeatures(EnumSet.allOf(SecurityFeature.class)) .globalFeatures(EnumSet.allOf(GlobalFeature.class)) .parameterFeatures(EnumSet.allOf(ParameterFeature.class)) .schemaSupportFeatures(EnumSet.allOf(SchemaSupportFeature.class)) ); embeddedTemplateDir = templateDir = "openapi"; outputFolder = "generated-code/openapi"; supportingFiles.add(new SupportingFile("README.md", "", "README.md")); }
Example #5
Source File: ApexClientCodegen.java From openapi-generator with Apache License 2.0 | 6 votes |
@Override public void preprocessOpenAPI(OpenAPI openAPI) { String calloutLabel = openAPI.getInfo().getTitle(); if (StringUtils.isNotBlank(namedCredential)) { calloutLabel = namedCredential; } additionalProperties.put("calloutLabel", calloutLabel); String sanitized = sanitizeName(calloutLabel); additionalProperties.put("calloutName", sanitized); supportingFiles.add(new SupportingFile("namedCredential.mustache", srcPath + "/namedCredentials", sanitized + ".namedCredential-meta.xml" )); if (additionalProperties.get(BUILD_METHOD).equals("sfdx")) { generateSfdxSupportingFiles(); } else if (additionalProperties.get(BUILD_METHOD).equals("ant")) { generateAntSupportingFiles(); } }
Example #6
Source File: SpringCloudMultiDirectoryStrategy.java From servicecomb-toolkit with Apache License 2.0 | 6 votes |
private void processProvider(List<SupportingFile> supportingFiles) { supportingFiles.add(new SupportingFile(providerTemplateFolder + "/applicationYml.mustache", resourcesFolder(providerDirectory()), "application.yml")); supportingFiles.add(new SupportingFile(providerTemplateFolder + "/pom.mustache", providerDirectory(), "pom.xml") ); supportingFiles.add(new SupportingFile(providerTemplateFolder + "/Application.mustache", mainClassFolder(providerDirectory()), "Application.java") ); propertiesMap.computeIfAbsent(GeneratorExternalConfigConstant.PROVIDER_ARTIFACT_ID, k -> providerDirectory()); propertiesMap .put(GeneratorExternalConfigConstant.PROVIDER_PROJECT_NAME, providerDirectory()); }
Example #7
Source File: KotlinClientCodegen.java From openapi-generator with Apache License 2.0 | 6 votes |
private void processJVMOkHttpLibrary(final String infrastructureFolder) { commonJvmMultiplatformSupportingFiles(infrastructureFolder); addSupportingSerializerAdapters(infrastructureFolder); additionalProperties.put(JVM, true); additionalProperties.put(JVM_OKHTTP, true); if (JVM_OKHTTP4.equals(getLibrary())) { additionalProperties.put(JVM_OKHTTP4, true); } else if (JVM_OKHTTP3.equals(getLibrary())) { additionalProperties.put(JVM_OKHTTP3, true); } supportedLibraries.put(JVM_OKHTTP, "A workaround to use the same template folder for both 'jvm-okhttp3' and 'jvm-okhttp4'."); setLibrary(JVM_OKHTTP); // jvm specific supporting files supportingFiles.add(new SupportingFile("infrastructure/ApplicationDelegates.kt.mustache", infrastructureFolder, "ApplicationDelegates.kt")); supportingFiles.add(new SupportingFile("infrastructure/Errors.kt.mustache", infrastructureFolder, "Errors.kt")); supportingFiles.add(new SupportingFile("infrastructure/ResponseExtensions.kt.mustache", infrastructureFolder, "ResponseExtensions.kt")); supportingFiles.add(new SupportingFile("infrastructure/ApiInfrastructureResponse.kt.mustache", infrastructureFolder, "ApiInfrastructureResponse.kt")); }
Example #8
Source File: SpringCloudProviderDirectoryStrategy.java From servicecomb-toolkit with Apache License 2.0 | 6 votes |
@Override public void processSupportingFile(List<SupportingFile> supportingFiles) { super.processSupportingFile(supportingFiles); supportingFiles.add(new SupportingFile(providerTemplateFolder + "/applicationYml.mustache", resourcesFolder(providerDirectory()), "application.yml")); supportingFiles.add(new SupportingFile(providerTemplateFolder + "/pom.mustache", providerDirectory(), "pom.xml") ); supportingFiles.add(new SupportingFile(providerTemplateFolder + "/Application.mustache", mainClassFolder(providerDirectory()), "Application.java") ); propertiesMap.computeIfAbsent(GeneratorExternalConfigConstant.PROVIDER_ARTIFACT_ID, k -> providerDirectory()); propertiesMap .put(GeneratorExternalConfigConstant.PROVIDER_PROJECT_NAME, providerDirectory()); }
Example #9
Source File: PhpClientCodegen.java From openapi-generator with Apache License 2.0 | 6 votes |
@Override public void processOpts() { super.processOpts(); supportingFiles.add(new SupportingFile("ApiException.mustache", toSrcPath(invokerPackage, srcBasePath), "ApiException.php")); supportingFiles.add(new SupportingFile("Configuration.mustache", toSrcPath(invokerPackage, srcBasePath), "Configuration.php")); supportingFiles.add(new SupportingFile("ObjectSerializer.mustache", toSrcPath(invokerPackage, srcBasePath), "ObjectSerializer.php")); supportingFiles.add(new SupportingFile("ModelInterface.mustache", toSrcPath(modelPackage, srcBasePath), "ModelInterface.php")); supportingFiles.add(new SupportingFile("HeaderSelector.mustache", toSrcPath(invokerPackage, srcBasePath), "HeaderSelector.php")); supportingFiles.add(new SupportingFile("composer.mustache", "", "composer.json")); supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); supportingFiles.add(new SupportingFile("phpunit.xml.mustache", "", "phpunit.xml.dist")); supportingFiles.add(new SupportingFile(".travis.yml", "", ".travis.yml")); supportingFiles.add(new SupportingFile(".php_cs", "", ".php_cs")); supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); }
Example #10
Source File: ScalaSttpClientCodegen.java From openapi-generator with Apache License 2.0 | 6 votes |
@Override public void processOpts() { super.processOpts(); if (additionalProperties.containsKey("mainPackage")) { setMainPackage((String) additionalProperties.get("mainPackage")); additionalProperties.replace("configKeyPath", this.configKeyPath); apiPackage = mainPackage + ".api"; modelPackage = mainPackage + ".model"; invokerPackage = mainPackage + ".core"; additionalProperties.put("apiPackage", apiPackage); additionalProperties.put("modelPackage", modelPackage); } supportingFiles.clear(); supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); supportingFiles.add(new SupportingFile("build.sbt.mustache", "", "build.sbt")); final String invokerFolder = (sourceFolder + File.separator + invokerPackage).replace(".", File.separator); supportingFiles.add(new SupportingFile("requests.mustache", invokerFolder, "requests.scala")); supportingFiles.add(new SupportingFile("apiInvoker.mustache", invokerFolder, "ApiInvoker.scala")); final String apiFolder = (sourceFolder + File.separator + apiPackage).replace(".", File.separator); supportingFiles.add(new SupportingFile("enumsSerializers.mustache", apiFolder, "EnumsSerializers.scala")); supportingFiles.add(new SupportingFile("serializers.mustache", invokerFolder, "Serializers.scala")); }
Example #11
Source File: ApexClientCodegen.java From openapi-generator with Apache License 2.0 | 5 votes |
private void generateAntSupportingFiles() { supportingFiles.add(new SupportingFile("package.mustache", "deploy", "package.xml")); supportingFiles.add(new SupportingFile("package.mustache", "undeploy", "destructiveChanges.xml")); supportingFiles.add(new SupportingFile("build.mustache", "build.xml")); supportingFiles.add(new SupportingFile("build.properties", "build.properties")); supportingFiles.add(new SupportingFile("remove.package.mustache", "undeploy", "package.xml")); supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); supportingFiles.add(new SupportingFile("README_ant.mustache", "README.md") .doNotOverwrite()); }
Example #12
Source File: PythonFlaskConnexionServerCodegen.java From openapi-generator with Apache License 2.0 | 5 votes |
@Override protected void addSupportingFiles() { supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); supportingFiles.add(new SupportingFile("Dockerfile.mustache", "", "Dockerfile")); supportingFiles.add(new SupportingFile("dockerignore.mustache", "", ".dockerignore")); supportingFiles.add(new SupportingFile("setup.mustache", "", "setup.py")); supportingFiles.add(new SupportingFile("tox.mustache", "", "tox.ini")); supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); supportingFiles.add(new SupportingFile("travis.mustache", "", ".travis.yml")); supportingFiles.add(new SupportingFile("encoder.mustache", packagePath(), "encoder.py")); supportingFiles.add(new SupportingFile("__init__test.mustache", packagePath() + File.separatorChar + testPackage, "__init__.py")); supportingFiles.add(new SupportingFile("__init__.mustache", packagePath(), "__init__.py")); testPackage = packageName + "." + testPackage; }
Example #13
Source File: TypeScriptJqueryClientCodegen.java From openapi-generator with Apache License 2.0 | 5 votes |
@Override public void processOpts() { super.processOpts(); supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); supportingFiles.add(new SupportingFile("models.mustache", modelPackage().replace('.', File.separatorChar), "models.ts")); supportingFiles.add(new SupportingFile("apis.mustache", apiPackage().replace('.', File.separatorChar), "api.ts")); supportingFiles.add(new SupportingFile("configuration.mustache", getIndexDirectory(), "configuration.ts")); supportingFiles.add(new SupportingFile("index.mustache", getIndexDirectory(), "index.ts")); supportingFiles.add(new SupportingFile("variables.mustache", getIndexDirectory(), "variables.ts")); if (additionalProperties.containsKey(NPM_NAME)) { addNpmPackageGeneration(); } }
Example #14
Source File: TypeScriptJqueryClientCodegen.java From openapi-generator with Apache License 2.0 | 5 votes |
private void addNpmPackageGeneration() { if (additionalProperties.containsKey(NPM_REPOSITORY)) { this.setNpmRepository(additionalProperties.get(NPM_REPOSITORY).toString()); } //Files for building our lib supportingFiles.add(new SupportingFile("README.mustache", getPackageRootDirectory(), "README.md")); supportingFiles.add(new SupportingFile("package.mustache", getPackageRootDirectory(), "package.json")); supportingFiles.add(new SupportingFile("tsconfig.mustache", getPackageRootDirectory(), "tsconfig.json")); }
Example #15
Source File: CppQt5ClientCodegen.java From openapi-generator with Apache License 2.0 | 5 votes |
@Override public void processOpts() { super.processOpts(); if (additionalProperties.containsKey(CodegenConstants.OPTIONAL_PROJECT_FILE)) { setOptionalProjectFileFlag(convertPropertyToBooleanAndWriteBack(CodegenConstants.OPTIONAL_PROJECT_FILE)); } else { additionalProperties.put(CodegenConstants.OPTIONAL_PROJECT_FILE, optionalProjectFileFlag); } if (additionalProperties.containsKey("modelNamePrefix")) { supportingFiles.clear(); supportingFiles.add(new SupportingFile("helpers-header.mustache", sourceFolder, modelNamePrefix + "Helpers.h")); supportingFiles.add(new SupportingFile("helpers-body.mustache", sourceFolder, modelNamePrefix + "Helpers.cpp")); supportingFiles.add(new SupportingFile("HttpRequest.h.mustache", sourceFolder, modelNamePrefix + "HttpRequest.h")); supportingFiles.add(new SupportingFile("HttpRequest.cpp.mustache", sourceFolder, modelNamePrefix + "HttpRequest.cpp")); supportingFiles.add(new SupportingFile("HttpFileElement.h.mustache", sourceFolder, modelNamePrefix + "HttpFileElement.h")); supportingFiles.add(new SupportingFile("HttpFileElement.cpp.mustache", sourceFolder, modelNamePrefix + "HttpFileElement.cpp")); supportingFiles.add(new SupportingFile("object.mustache", sourceFolder, modelNamePrefix + "Object.h")); supportingFiles.add(new SupportingFile("enum.mustache", sourceFolder, modelNamePrefix + "Enum.h")); supportingFiles.add(new SupportingFile("CMakeLists.txt.mustache", sourceFolder, "CMakeLists.txt")); typeMapping.put("file", modelNamePrefix + "HttpFileElement"); importMapping.put(modelNamePrefix + "HttpFileElement", "#include \"" + modelNamePrefix + "HttpFileElement.h\""); if (optionalProjectFileFlag) { supportingFiles.add(new SupportingFile("Project.mustache", sourceFolder, modelNamePrefix + "client.pri")); } } }
Example #16
Source File: ServiceCombCodegenTest.java From servicecomb-toolkit with Apache License 2.0 | 5 votes |
@Test public void spirngCloudMultiDirectoryStrategy() { SpringCloudMultiDirectoryStrategy multiDirectoryStrategy = new SpringCloudMultiDirectoryStrategy(); Map<String, Object> propertiesMap = new HashMap<>(); propertiesMap.put("artifactId", "all"); propertiesMap.put("mainClassPackage", "all"); propertiesMap.put("apiTemplateFiles", new HashMap<String, String>()); multiDirectoryStrategy.addCustomProperties(propertiesMap); multiDirectoryStrategy.processSupportingFile(new ArrayList<SupportingFile>()); Assert.assertEquals("consumer", multiDirectoryStrategy.consumerDirectory()); Assert.assertEquals("provider", multiDirectoryStrategy.providerDirectory()); Assert.assertEquals("model", multiDirectoryStrategy.modelDirectory()); }
Example #17
Source File: ProviderDirectoryStrategy.java From servicecomb-toolkit with Apache License 2.0 | 5 votes |
@Override public void processSupportingFile(List<SupportingFile> supportingFiles) { super.processSupportingFile(supportingFiles); supportingFiles.add(new SupportingFile("pom.mustache", providerDirectory(), "pom.xml") ); supportingFiles.add(new SupportingFile("Application.mustache", mainClassFolder(providerDirectory()), "Application.java") ); supportingFiles.add(new SupportingFile("log4j2.mustache", resourcesFolder(providerDirectory()), "log4j2.xml") ); supportingFiles.add(new SupportingFile(providerTemplateFolder + "/microservice.mustache", resourcesFolder(providerDirectory()), "microservice.yaml") ); propertiesMap .computeIfAbsent(GeneratorExternalConfigConstant.PROVIDER_ARTIFACT_ID, k -> propertiesMap.get("artifactId")); propertiesMap .put(GeneratorExternalConfigConstant.PROVIDER_PROJECT_NAME, providerDirectory()); if (ServiceCombCodegen.POJO_LIBRARY.equals(propertiesMap.get("library"))) { // ((Map<String, String>) propertiesMap.get("apiTemplateFiles")).put(pojoApiImplTemplate, ".java"); propertiesMap.put("isPOJO", true); } propertiesMap.put("isMultipleModule", false); }
Example #18
Source File: SpringCloudMultiDirectoryStrategy.java From servicecomb-toolkit with Apache License 2.0 | 5 votes |
@Override public void processSupportingFile(List<SupportingFile> supportingFiles) { super.processSupportingFile(supportingFiles); processProvider(supportingFiles); processConsumer(supportingFiles); processModel(supportingFiles); propertiesMap.put("isMultipleModule", true); supportingFiles.add(new SupportingFile("project/pom.mustache", "", "pom.xml") ); }
Example #19
Source File: DefaultDirectoryStrategy.java From servicecomb-toolkit with Apache License 2.0 | 5 votes |
private void processProvider(List<SupportingFile> supportingFiles) { supportingFiles.add(new SupportingFile("pom.mustache", providerDirectory(), "pom.xml") ); supportingFiles.add(new SupportingFile("Application.mustache", mainClassFolder(providerDirectory()), "Application.java") ); supportingFiles.add(new SupportingFile("log4j2.mustache", resourcesFolder(providerDirectory()), "log4j2.xml") ); supportingFiles.add(new SupportingFile(providerTemplateFolder + "/microservice.mustache", resourcesFolder(providerDirectory()), "microservice.yaml") ); propertiesMap .computeIfAbsent(GeneratorExternalConfigConstant.PROVIDER_ARTIFACT_ID, k -> providerDirectory()); if (ServiceCombCodegen.POJO_LIBRARY.equals(propertiesMap.get("library"))) { // ((Map<String, String>) propertiesMap.get("apiTemplateFiles")).put(pojoApiImplTemplate, ".java"); propertiesMap.put("isPOJO", true); } }
Example #20
Source File: ApexClientCodegen.java From openapi-generator with Apache License 2.0 | 5 votes |
private void postProcessOpts() { supportingFiles.add( new SupportingFile("client.mustache", srcPath + "classes", classPrefix + "Client.cls")); supportingFiles.add(new SupportingFile("cls-meta.mustache", srcPath + "classes", classPrefix + "Client.cls-meta.xml" )); }
Example #21
Source File: DefaultDirectoryStrategy.java From servicecomb-toolkit with Apache License 2.0 | 5 votes |
@Override public void processSupportingFile(List<SupportingFile> supportingFiles) { super.processSupportingFile(supportingFiles); processProvider(supportingFiles); processConsumer(supportingFiles); processModel(supportingFiles); processParentProjectOpts(supportingFiles); propertiesMap.put("isMultipleModule", true); }
Example #22
Source File: CppQt5QHttpEngineServerCodegen.java From openapi-generator with Apache License 2.0 | 5 votes |
@Override public void processOpts() { super.processOpts(); if (additionalProperties.containsKey("modelNamePrefix")) { supportingFiles.clear(); supportingFiles.add(new SupportingFile("helpers-header.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "Helpers.h")); supportingFiles.add(new SupportingFile("helpers-body.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "Helpers.cpp")); supportingFiles.add(new SupportingFile("object.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "Object.h")); supportingFiles.add(new SupportingFile("enum.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "Enum.h")); supportingFiles.add(new SupportingFile("HttpFileElement.h.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "HttpFileElement.h")); supportingFiles.add(new SupportingFile("HttpFileElement.cpp.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "HttpFileElement.cpp")); supportingFiles.add(new SupportingFile("apirouter.h.mustache", sourceFolder + APIHANDLER_DIR, modelNamePrefix + "ApiRouter.h")); supportingFiles.add(new SupportingFile("apirouter.cpp.mustache", sourceFolder + APIHANDLER_DIR, modelNamePrefix + "ApiRouter.cpp")); supportingFiles.add(new SupportingFile("main.cpp.mustache", sourceFolder + SRC_DIR, "main.cpp")); supportingFiles.add(new SupportingFile("src-CMakeLists.txt.mustache", sourceFolder + SRC_DIR, "CMakeLists.txt")); supportingFiles.add(new SupportingFile("README.md.mustache", sourceFolder, "README.MD")); supportingFiles.add(new SupportingFile("Makefile.mustache", sourceFolder, "Makefile")); supportingFiles.add(new SupportingFile("CMakeLists.txt.mustache", sourceFolder, "CMakeLists.txt")); supportingFiles.add(new SupportingFile("Dockerfile.mustache", sourceFolder, "Dockerfile")); supportingFiles.add(new SupportingFile("LICENSE.txt.mustache", sourceFolder, "LICENSE.txt")); typeMapping.put("file", modelNamePrefix + "HttpFileElement"); importMapping.put(modelNamePrefix + "HttpFileElement", "#include \"" + modelNamePrefix + "HttpFileElement.h\""); } }
Example #23
Source File: JavaVertXWebServerCodegen.java From openapi-generator with Apache License 2.0 | 5 votes |
@Override public void processOpts() { super.processOpts(); apiTestTemplateFiles.clear(); importMapping.remove("JsonCreator"); importMapping.remove("com.fasterxml.jackson.annotation.JsonProperty"); importMapping.put("JsonInclude", "com.fasterxml.jackson.annotation.JsonInclude"); importMapping.put("JsonProperty", "com.fasterxml.jackson.annotation.JsonProperty"); importMapping.put("JsonValue", "com.fasterxml.jackson.annotation.JsonValue"); importMapping.put("FileUpload", "io.vertx.ext.web.FileUpload"); modelDocTemplateFiles.clear(); apiDocTemplateFiles.clear(); String sourcePackageFolder = sourceFolder + File.separator + invokerPackage.replace(".", File.separator); supportingFiles.clear(); supportingFiles.add(new SupportingFile("supportFiles/openapi.mustache", resourceFolder, "openapi.yaml")); supportingFiles.add(new SupportingFile("supportFiles/HttpServerVerticle.mustache", sourcePackageFolder, "HttpServerVerticle.java")); supportingFiles.add(new SupportingFile("supportFiles/MainVerticle.mustache", sourcePackageFolder, "MainVerticle.java")); supportingFiles.add(new SupportingFile("supportFiles/ApiResponse.mustache", sourcePackageFolder, "ApiResponse.java")); supportingFiles.add(new SupportingFile("supportFiles/ApiException.mustache", sourcePackageFolder, "ApiException.java")); supportingFiles.add(new SupportingFile("supportFiles/ParameterCast.mustache", sourcePackageFolder, "ParameterCast.java")); supportingFiles.add(new SupportingFile("supportFiles/pom.mustache", "", "pom.xml")); supportingFiles.add(new SupportingFile("README.mustache", "", "README.md") .doNotOverwrite()); }
Example #24
Source File: TypeScriptAngularJsClientCodegen.java From openapi-generator with Apache License 2.0 | 5 votes |
@Override public void processOpts() { super.processOpts(); supportingFiles.add(new SupportingFile("models.mustache", modelPackage().replace('.', File.separatorChar), "models.ts")); supportingFiles.add(new SupportingFile("apis.mustache", apiPackage().replace('.', File.separatorChar), "api.ts")); supportingFiles.add(new SupportingFile("index.mustache", getIndexDirectory(), "index.ts")); supportingFiles.add(new SupportingFile("api.module.mustache", getIndexDirectory(), "api.module.ts")); supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); supportingFiles.add(new SupportingFile("gitignore", "", ".gitignore")); }
Example #25
Source File: KotlinClientCodegen.java From openapi-generator with Apache License 2.0 | 5 votes |
private void processJVMRetrofit2Library(String infrastructureFolder) { additionalProperties.put(JVM, true); additionalProperties.put(JVM_RETROFIT2, true); supportingFiles.add(new SupportingFile("infrastructure/ApiClient.kt.mustache", infrastructureFolder, "ApiClient.kt")); supportingFiles.add(new SupportingFile("infrastructure/ResponseExt.kt.mustache", infrastructureFolder, "ResponseExt.kt")); supportingFiles.add(new SupportingFile("infrastructure/CollectionFormats.kt.mustache", infrastructureFolder, "CollectionFormats.kt")); addSupportingSerializerAdapters(infrastructureFolder); }
Example #26
Source File: PythonAiohttpConnexionServerCodegen.java From openapi-generator with Apache License 2.0 | 5 votes |
@Override protected void addSupportingFiles() { supportingFiles.add(new SupportingFile("conftest.mustache", testPackage, "conftest.py")); supportingFiles.add(new SupportingFile("__init__test.mustache", testPackage, "__init__.py")); supportingFiles.add(new SupportingFile("__init__main.mustache", packagePath(), "__init__.py")); supportingFiles.add(new SupportingFile("setup.mustache", "", "setup.py")); supportingFiles.add(new SupportingFile("tox.mustache", "", "tox.ini")); supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); }
Example #27
Source File: TypeScriptAxiosClientCodegen.java From openapi-generator with Apache License 2.0 | 5 votes |
@Override public void processOpts() { super.processOpts(); tsModelPackage = modelPackage.replaceAll("\\.", "/"); String tsApiPackage = apiPackage.replaceAll("\\.", "/"); String modelRelativeToRoot = getRelativeToRoot(tsModelPackage); String apiRelativeToRoot = getRelativeToRoot(tsApiPackage); additionalProperties.put("tsModelPackage", tsModelPackage); additionalProperties.put("tsApiPackage", tsApiPackage); additionalProperties.put("apiRelativeToRoot", apiRelativeToRoot); additionalProperties.put("modelRelativeToRoot", modelRelativeToRoot); supportingFiles.add(new SupportingFile("index.mustache", "", "index.ts")); supportingFiles.add(new SupportingFile("baseApi.mustache", "", "base.ts")); supportingFiles.add(new SupportingFile("api.mustache", "", "api.ts")); supportingFiles.add(new SupportingFile("configuration.mustache", "", "configuration.ts")); supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); supportingFiles.add(new SupportingFile("gitignore", "", ".gitignore")); supportingFiles.add(new SupportingFile("npmignore", "", ".npmignore")); if (additionalProperties.containsKey(SEPARATE_MODELS_AND_API)) { boolean separateModelsAndApi = Boolean.parseBoolean(additionalProperties.get(SEPARATE_MODELS_AND_API).toString()); if (separateModelsAndApi) { if (StringUtils.isAnyBlank(modelPackage, apiPackage)) { throw new RuntimeException("apiPackage and modelPackage must be defined"); } modelTemplateFiles.put("model.mustache", ".ts"); apiTemplateFiles.put("apiInner.mustache", ".ts"); supportingFiles.add(new SupportingFile("modelIndex.mustache", tsModelPackage, "index.ts")); } } if (additionalProperties.containsKey(NPM_NAME)) { addNpmPackageGeneration(); } }
Example #28
Source File: TypeScriptAxiosClientCodegen.java From openapi-generator with Apache License 2.0 | 5 votes |
private void addNpmPackageGeneration() { if (additionalProperties.containsKey(NPM_REPOSITORY)) { this.setNpmRepository(additionalProperties.get(NPM_REPOSITORY).toString()); } //Files for building our lib supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); supportingFiles.add(new SupportingFile("package.mustache", "", "package.json")); supportingFiles.add(new SupportingFile("tsconfig.mustache", "", "tsconfig.json")); }
Example #29
Source File: Meta.java From openapi-generator with Apache License 2.0 | 5 votes |
/** * Converter method to process supporting files: execute with mustache, or simply copy to * destination directory * * @param targetDir - destination directory * @param data - map with additional params needed to process templates * @return converter object to pass to lambdaj */ private static Converter<SupportingFile, File> processFiles(final File targetDir, final Map<String, Object> data) { return support -> { try { File destinationFolder = new File(new File(targetDir.getAbsolutePath()), support.folder); File outputFile = new File(destinationFolder, support.destinationFilename); TemplateManager templateProcessor = new TemplateManager( new TemplateManagerOptions(false, false), new MustacheEngineAdapter(), new TemplatePathLocator[]{ new CommonTemplateContentLocator("codegen") } ); String template = templateProcessor.readTemplate(new File(TEMPLATE_DIR_CLASSPATH, support.templateFile).getPath()); String formatted = template; Mustache.TemplateLoader loader = name -> templateProcessor.getTemplateReader(name.concat(MUSTACHE_EXTENSION)); if (support.templateFile.endsWith(MUSTACHE_EXTENSION)) { LOGGER.info("writing file to {}", outputFile.getAbsolutePath()); formatted = Mustache.compiler().withLoader(loader).defaultValue("") .compile(template).execute(data); } else { LOGGER.info("copying file to {}", outputFile.getAbsolutePath()); } FileUtils.writeStringToFile(outputFile, formatted, StandardCharsets.UTF_8); return outputFile; } catch (IOException e) { throw new RuntimeException("Can't generate project", e); } }; }
Example #30
Source File: TeiidCodegen.java From teiid-spring-boot with Apache License 2.0 | 5 votes |
private void removeSupportingFile(String name) { SupportingFile found = null; for (SupportingFile f : supportingFiles) { if(f.destinationFilename.contentEquals(name)) { found = f; } } if (found != null) { supportingFiles.remove(found); } }