public class OpenAPICodegenUtils extends Object
| Constructor and Description |
|---|
OpenAPICodegenUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addDefaultAuthProviders(List<String> authProviders) |
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)
Get auth providers for given schema.
|
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)
Get resource level auth providers as a list of strings.
|
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.
|
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(String apiName,
String version,
Map<String,Object> apiDefExtensions,
String mutualSSL)
Get application security from API Definition extension.
|
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 |
setOauthSecuritySchemaList(io.swagger.v3.oas.models.OpenAPI openAPI)
store the security schemas of type "oauth2".
|
static void |
setOpenAPIDefinitionEndpointReferenceExtensions(Map<String,Object> extensions)
store the endpoint extensions which are used as references.
|
static void |
setSecuritySchemaList(io.swagger.v3.oas.models.OpenAPI openAPI)
store the security schemas of type "basic" and "apikey".
|
static void |
validateOpenAPIDefinition(io.swagger.v3.oas.models.OpenAPI openAPI,
String openAPIFilePath,
String openAPIVersion)
validate the openAPI definition.
|
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 setAdditionalConfigsDevFirst(ExtendedAPI api, io.swagger.v3.oas.models.OpenAPI openAPI, String openAPIFilePath)
public static MgwEndpointConfigDTO getResourceEpConfigForCodegen(io.swagger.v3.oas.models.Operation operation) throws CLICompileTimeException
MgwEndpointConfigDTO to match the mustache
template.operation - Operation objectMgwEndpointConfigDTO objectCLICompileTimeExceptionpublic static void setInterceptors(String projectName) throws IOException
IOException - if an error occurred while reading the bal files inside interceptor directorypublic static ApplicationSecurity populateApplicationSecurity(String apiName, String version, Map<String,Object> apiDefExtensions, String mutualSSL)
apiDefExtensions - API definition extesnsionspublic static List<String> getMgwResourceSecurity(io.swagger.v3.oas.models.Operation operation, ApplicationSecurity appSecurity)
operation - operation OperationappSecurity - Application security object ApplicationSecuritypublic 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 void setOauthSecuritySchemaList(io.swagger.v3.oas.models.OpenAPI openAPI)
openAPI - OpenAPI objectpublic static void setSecuritySchemaList(io.swagger.v3.oas.models.OpenAPI openAPI)
openAPI - OpenAPI objectpublic static void setOpenAPIDefinitionEndpointReferenceExtensions(Map<String,Object> extensions)
extensions - Map objectpublic static List<String> getAuthProviders(String schemas, ApplicationSecurity appSecurity)
schemas - oas definition schemasappSecurity - security defined by the extensionCopyright © 2021 WSO2. All rights reserved.