public class OpenAPICodegenUtils extends Object
| Constructor and Description |
|---|
OpenAPICodegenUtils() |
| Modifier and Type | Method and Description |
|---|---|
static String |
convertYamlToJson(String yaml) |
static String |
findSwaggerVersion(String apiDefinition,
boolean isFilePath)
Discover the openAPI version of the given API definition
|
static ExtendedAPI |
generateAPIFromOpenAPIDef(io.swagger.v3.oas.models.OpenAPI openAPI,
String openAPIContent)
generate ExtendedAPI object from openAPI definition.
|
static List<APIKey> |
generateAPIKeysFromSecurity(List<io.swagger.v3.oas.models.security.SecurityRequirement> securityRequirementList,
boolean isAPIKeyEnabled)
Provide api keys for a given security requirement list
|
static ExtendedAPI |
generateGrpcAPIFromOpenAPI(io.swagger.v3.oas.models.OpenAPI openAPI)
Generate
ExtendedAPI object from generated OpenAPI from protobuf file. |
static List<String> |
getAuthProviders(String schemas,
ApplicationSecurity appSecurity) |
static String |
getMgwResourceScope(io.swagger.v3.oas.models.Operation operation)
Get resource level security scopes of
Operation if the security scheme is oauth2. |
static List<String> |
getMgwResourceSecurity(io.swagger.v3.oas.models.Operation operation,
ApplicationSecurity appSecurity) |
static String |
getOpenAPIAsJson(io.swagger.v3.oas.models.OpenAPI openAPI,
String openAPIContent,
Path openAPIPath)
Convert the v2 or v3 open API definition in yaml or json format into json format of the respective format
v2/YAML -> v2/JSON
v3/YAML -> v3/JSON
|
static MgwEndpointConfigDTO |
getResourceEpConfigForCodegen(io.swagger.v3.oas.models.Operation operation)
get resource Endpoint configuration in the format of
MgwEndpointConfigDTO to match the mustache
template |
static ApplicationSecurity |
populateApplicationSecurity(Map<String,Object> apiDefExtensions,
String mutualSSL)
Get application security from API Definition extension.
|
static void |
setAdditionalConfig(ExtendedAPI api) |
static void |
setAdditionalConfigsDevFirst(ExtendedAPI api,
io.swagger.v3.oas.models.OpenAPI openAPI,
String openAPIFilePath) |
static void |
setInterceptors(String projectName)
Store all the interceptor functions included in interceptors directory.
|
static void |
validateOpenAPIDefinition(io.swagger.v3.oas.models.OpenAPI openAPI,
String openAPIFilePath,
String openAPIVersion)
validate the openAPI definition
|
static void |
writeDependencies(String projectName,
BallerinaService definitionContext)
Write ballerina dependency libraries to Ballerina.toml.
|
public static String findSwaggerVersion(String apiDefinition, boolean isFilePath)
apiDefinition - API definition (as a file path or String content)isFilePath - If the given api Definition is a file pathpublic static String getOpenAPIAsJson(io.swagger.v3.oas.models.OpenAPI openAPI, String openAPIContent, Path openAPIPath)
openAPIContent - open API as a string contentpublic static String convertYamlToJson(String yaml) throws IOException
IOExceptionpublic static ExtendedAPI generateAPIFromOpenAPIDef(io.swagger.v3.oas.models.OpenAPI openAPI, String openAPIContent) throws IOException
openAPI - OpenAPI object with all required propertiesExtendedAPI objectIOExceptionpublic static ExtendedAPI generateGrpcAPIFromOpenAPI(io.swagger.v3.oas.models.OpenAPI openAPI)
ExtendedAPI object from generated OpenAPI from protobuf file. This is used for the ballerina
service generation.openAPI - OpenAPI object with all required propertiesExtendedAPI object for protobufpublic static void setAdditionalConfig(ExtendedAPI api)
public static void setAdditionalConfigsDevFirst(ExtendedAPI api, io.swagger.v3.oas.models.OpenAPI openAPI, String openAPIFilePath)
public static MgwEndpointConfigDTO getResourceEpConfigForCodegen(io.swagger.v3.oas.models.Operation operation)
MgwEndpointConfigDTO to match the mustache
templateoperation - Operation objectMgwEndpointConfigDTO objectpublic static void setInterceptors(String projectName) throws IOException
IOException - if an error occurred while reading the bal files inside interceptor directorypublic static void writeDependencies(String projectName, BallerinaService definitionContext)
projectName - The project namedefinitionContext - Currently built ballerina service contextpublic static ApplicationSecurity populateApplicationSecurity(Map<String,Object> apiDefExtensions, String mutualSSL)
apiDefExtensions - API definition extesnsionspublic static List<String> getMgwResourceSecurity(io.swagger.v3.oas.models.Operation operation, ApplicationSecurity appSecurity)
public static String getMgwResourceScope(io.swagger.v3.oas.models.Operation operation)
Operation if the security scheme is oauth2.operation - Operationpublic static List<APIKey> generateAPIKeysFromSecurity(List<io.swagger.v3.oas.models.security.SecurityRequirement> securityRequirementList, boolean isAPIKeyEnabled)
securityRequirementList - List objectpublic static void validateOpenAPIDefinition(io.swagger.v3.oas.models.OpenAPI openAPI,
String openAPIFilePath,
String openAPIVersion)
openAPI - OpenAPI objectopenAPIFilePath - file path to openAPI definitionpublic static List<String> getAuthProviders(String schemas, ApplicationSecurity appSecurity)
Copyright © 2020 WSO2. All rights reserved.