public class OpenAPICodegenUtils extends Object
| Constructor and Description |
|---|
OpenAPICodegenUtils() |
| Modifier and Type | Method and Description |
|---|---|
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,
Path openAPIPath)
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 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 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 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 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)
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 ExtendedAPI generateAPIFromOpenAPIDef(io.swagger.v3.oas.models.OpenAPI openAPI, Path openAPIPath) throws IOException
openAPI - OpenAPI objectIOExceptionpublic static List<ResourceRepresentation> listResourcesFromSwaggerForAPI(String projectName, String apiId)
projectName - project NameapiId - api Idpublic static ResourceRepresentation getResource(String projectName, String resource_id)
projectName - project nameresource_id - resource idpublic 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.