-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1616 from lnash94/bal-build-master
[master] Integrate Client generation for the Bal build command
- Loading branch information
Showing
74 changed files
with
1,663 additions
and
567 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). | ||
* | ||
* WSO2 LLC. licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
|
||
apply from: "$rootDir/gradle/javaProject.gradle" | ||
apply plugin: "com.github.johnrengelman.shadow" | ||
apply plugin: "java-library" | ||
|
||
description = "OpenAPI Tooling - OpenAPI to Ballerina" | ||
|
||
configurations.all { | ||
resolutionStrategy.preferProjectModules() | ||
} | ||
|
||
dependencies { | ||
implementation project(':openapi-core') | ||
implementation("io.swagger.parser.v3:swagger-parser:${swaggerParserVersion}") { | ||
exclude group: "io.swagger", module: "swagger-compat-spec-parser" | ||
exclude group: "org.slf4j", module: "slf4j-ext" | ||
exclude group: "javax.validation", module: "validation-api" | ||
} | ||
implementation "org.ballerinalang:ballerina-lang" | ||
implementation "org.ballerinalang:ballerina-parser" | ||
implementation "org.ballerinalang:formatter-core" | ||
implementation "org.ballerinalang:ballerina-cli" | ||
implementation "org.ballerinalang:ballerina-tools-api" | ||
implementation "org.ballerinalang:toml-parser:${ballerinaLangVersion}" | ||
implementation "com.google.code.findbugs:jsr305" | ||
implementation "commons-codec:commons-codec:${commonsCodecVersion}" | ||
testImplementation "org.testng:testng" | ||
} | ||
|
||
shadowJar { | ||
configurations = [project.configurations.runtimeClasspath] | ||
dependencies { | ||
include(dependency("commons-codec:commons-codec:${commonsCodecVersion}")) | ||
include(dependency('io.swagger.parser.v3:swagger-parser')) | ||
exclude('META-INF/*.SF') | ||
exclude('META-INF/*.DSA') | ||
exclude('META-INF/*.RSA') | ||
} | ||
// Customize the JAR file name without the '-all' suffix | ||
archiveFileName = "openapi-bal-task-plugin-${project.version}.jar" | ||
} | ||
|
||
compileJava { | ||
doFirst { | ||
options.compilerArgs = [ | ||
'--module-path', classpath.asPath, | ||
] | ||
classpath = files() | ||
} | ||
} | ||
build.dependsOn shadowJar | ||
|
||
// Disable the default 'jar' task | ||
tasks.named('jar').configure { | ||
enabled = false | ||
} |
83 changes: 83 additions & 0 deletions
83
openapi-bal-task-plugin/src/main/java/io/ballerina/openapi/bal/tool/Constants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). | ||
* | ||
* WSO2 LLC. licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package io.ballerina.openapi.bal.tool; | ||
|
||
import io.ballerina.tools.diagnostics.DiagnosticSeverity; | ||
|
||
/** | ||
* This class includes constants for ballerina package build generator. | ||
* | ||
* @since 1.9.0 | ||
*/ | ||
public class Constants { | ||
public static final String TAGS = "tags"; | ||
public static final String OPERATIONS = "operations"; | ||
public static final String NULLABLE = "nullable"; | ||
public static final String CLIENT_METHODS = "clientMethods"; | ||
public static final String LICENSE = "license"; | ||
public static final String TRUE = "true"; | ||
public static final String MODE = "mode"; | ||
public static final String CLIENT = "client"; | ||
public static final String CACHE_FILE = "openapi-cache.txt"; | ||
|
||
/** | ||
* Enum class for containing diagnostic messages. | ||
*/ | ||
public enum DiagnosticMessages { | ||
LICENSE_PATH_BLANK("OAS_CLIENT_01", "given license file path is an empty string.", | ||
DiagnosticSeverity.WARNING), | ||
ERROR_WHILE_READING_LICENSE_FILE("OAS_CLIENT_02", "unexpected error occurred while reading the license", | ||
DiagnosticSeverity.ERROR), | ||
ERROR_WHILE_GENERATING_CLIENT("OAS_CLIENT_03", "unexpected error occurred while generating the client", | ||
DiagnosticSeverity.ERROR), | ||
PARSER_ERROR("OAS_CLIENT_04", "", DiagnosticSeverity.ERROR), | ||
UNEXPECTED_EXCEPTIONS("OAS_CLIENT_05", "unexpected error occurred while reading the contract", | ||
DiagnosticSeverity.ERROR), | ||
EMPTY_CONTRACT_PATH("OAS_CLIENT_06", "given openapi contract file path is an empty string.", | ||
DiagnosticSeverity.ERROR), | ||
WARNING_FOR_OTHER_GENERATION("OAS_CLIENT_07", "`%s` mode does not support for bal build code generation.", | ||
DiagnosticSeverity.ERROR), | ||
WARNING_FOR_UNSUPPORTED_CONTRACT("OAS_CLIENT_08", "unsupported contract type. please use .yml, " + | ||
".yaml, or .json files for code generation.", | ||
DiagnosticSeverity.ERROR), | ||
INVALID_CONTRACT_PATH("OAS_CLIENT_09", "invalid openapi contract file path.", | ||
DiagnosticSeverity.ERROR); | ||
|
||
private final String code; | ||
private final String description; | ||
private final DiagnosticSeverity severity; | ||
|
||
DiagnosticMessages(String code, String description, DiagnosticSeverity severity) { | ||
this.code = code; | ||
this.description = description; | ||
this.severity = severity; | ||
} | ||
|
||
public String getCode() { | ||
return code; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public DiagnosticSeverity getSeverity() { | ||
return severity; | ||
} | ||
} | ||
} |
Oops, something went wrong.