public class OpenAPICodegenUtils extends Object
| Constructor and Description |
|---|
OpenAPICodegenUtils() |
| Modifier and Type | Method and Description |
|---|---|
static String |
generateAPIdForSwagger(String apiDefPath)
Generate API Id for a given OpenAPI definition.
|
static ExtendedAPI |
generateAPIFromOpenAPIDef(io.swagger.v3.oas.models.OpenAPI openAPI)
generate ExtendedAPI object from openAPI definition
|
static BasicAuth |
generateBasicAuthFromSecurity(String schemas)
When the security schema string is provided as a comma separated set of values
generate the corresponding schema string.
|
static List<ResourceRepresentation> |
getAllResources(String projectName)
List all the resources available in the project
|
static String |
getBasePathFromSwagger(String apiDefPath)
get basePath from the openAPI definition
|
static BasicAuth |
getMgwResourceBasicAuth(io.swagger.v3.oas.models.Operation operation) |
static String |
getMgwResourceScope(io.swagger.v3.oas.models.Operation operation)
Get resource level security scopes of
Operation if the security scheme is oauth2. |
static ResourceRepresentation |
getResource(String projectName,
String resource_id)
get the resource related information if the resource_id is given
|
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 List<ResourceRepresentation> |
listResourcesFromSwaggerForAPI(String projectName,
String apiId)
list all the available resources from openAPI definition
|
static String |
readJson(String filePath)
read openAPI definition
|
static void |
setAdditionalConfig(ExtendedAPI api) |
static void |
setAdditionalConfigsDevFirst(ExtendedAPI api)
set additional configurations for an api for code generation process (basePath and CORS configuration)
|
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)
validate the openAPI definition
|
public static String generateAPIdForSwagger(String apiDefPath)
apiDefPath - path to OpenAPI definitionpublic static String getBasePathFromSwagger(String apiDefPath)
apiDefPath - path to openAPI definitionpublic static ExtendedAPI generateAPIFromOpenAPIDef(io.swagger.v3.oas.models.OpenAPI openAPI)
openAPI - OpenAPI objectpublic static List<ResourceRepresentation> listResourcesFromSwaggerForAPI(String projectName, String apiId)
projectName - project NameapiId - api Idpublic static List<ResourceRepresentation> getAllResources(String projectName)
projectName - project Namepublic static ResourceRepresentation getResource(String projectName, String resource_id)
projectName - project nameresource_id - resource idpublic static String readJson(String filePath)
filePath - path to openAPI definitionpublic static void setAdditionalConfigsDevFirst(ExtendedAPI api)
api - API objectpublic 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 BasicAuth getMgwResourceBasicAuth(io.swagger.v3.oas.models.Operation operation)
public static String getMgwResourceScope(io.swagger.v3.oas.models.Operation operation)
Operation if the security scheme is oauth2.operation - Operationpublic static BasicAuth generateBasicAuthFromSecurity(String schemas)
schemas - comma separated security security schema types (ex. basic,oauth2)BasicAuth objectpublic static void validateOpenAPIDefinition(io.swagger.v3.oas.models.OpenAPI openAPI,
String openAPIFilePath)
openAPI - OpenAPI objectopenAPIFilePath - file path to openAPI definitionCopyright © 2019 WSO2. All rights reserved.