Class SwaggerGenerator
- java.lang.Object
-
- org.wso2.carbon.mediation.transport.handlers.requestprocessors.swagger.format.SwaggerGenerator
-
- Direct Known Subclasses:
SwaggerJsonProcessor
,SwaggerYamlProcessor
public class SwaggerGenerator extends Object
This is the base class used by swagger formatter classes(JSON and YAML) and contains generic functions.
-
-
Constructor Summary
Constructors Constructor Description SwaggerGenerator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.apache.synapse.api.API
getAPIFromSynapseConfig(org.wso2.carbon.core.transports.CarbonHttpRequest request)
Returns API instance related to the URI in provided request.protected String
getApiNameFromRequestUri(String requestUri)
Extract API Name from the given URI.protected void
handleException(String errorMsg)
Logs the error message and throws New AxisFault.protected String
retrieveAPISwaggerFromRegistry(org.apache.synapse.api.API api, String requestURI)
Function to extract swagger definition from the registryprotected void
updateResponse(org.wso2.carbon.core.transports.CarbonHttpResponse response, String responseString, String contentType)
Update the response with provided response string.
-
-
-
Method Detail
-
updateResponse
protected void updateResponse(org.wso2.carbon.core.transports.CarbonHttpResponse response, String responseString, String contentType) throws org.apache.axis2.AxisFault
Update the response with provided response string.- Parameters:
response
- CarbonHttpResponse which will be updatedresponseString
- String response to be updated in responsecontentType
- Content type of the response to be updated in response headaers- Throws:
Exception
- Any exception occured during the updateorg.apache.axis2.AxisFault
-
getAPIFromSynapseConfig
protected org.apache.synapse.api.API getAPIFromSynapseConfig(org.wso2.carbon.core.transports.CarbonHttpRequest request)
Returns API instance related to the URI in provided request.- Parameters:
request
- CarbonHttpRequest which contains the request URI info- Returns:
- API instance with respect to the request
-
getApiNameFromRequestUri
protected String getApiNameFromRequestUri(String requestUri)
Extract API Name from the given URI.- Parameters:
requestUri
- URI String of the request- Returns:
- API Name extracted from the URI provided
-
retrieveAPISwaggerFromRegistry
protected String retrieveAPISwaggerFromRegistry(org.apache.synapse.api.API api, String requestURI) throws org.wso2.carbon.registry.core.exceptions.RegistryException
Function to extract swagger definition from the registry- Parameters:
api
- API objectrequestURI
- request URI info- Returns:
- null if registry content unavailable or empty, otherwise relevant content
- Throws:
org.wso2.carbon.registry.core.exceptions.RegistryException
-
handleException
protected void handleException(String errorMsg) throws org.apache.axis2.AxisFault
Logs the error message and throws New AxisFault.- Parameters:
errorMsg
- String message which contains error information- Throws:
org.apache.axis2.AxisFault
- throws with error information
-
-