public abstract class ResourceParser extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
CATCH_ALL_MEDIA_TYPE |
protected static String |
CSRF_HEADER |
protected String |
defaultMediaType |
protected static Pattern |
IGNORE_METHOD_REGEX |
protected JavaDocExtractor |
javaDocs |
protected static org.slf4j.Logger |
logger |
protected String |
version |
| Constructor and Description |
|---|
ResourceParser(File javaDocPath,
String version,
String defaultMediaType) |
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
addHeadersForMethod(RamlAction action,
RamlActionType actionType,
Method method)
Allows children to add common headers to API methods (eg CSRF, Authorization)
|
static boolean |
doesActionTypeSupportMultipartMime(RamlActionType target)
Method to check if a specific action type supports multipart mime request
|
static boolean |
doesActionTypeSupportRequestBody(RamlActionType target)
Method to check if a specific action type supports payloads in the body of the request
|
protected abstract void |
extractAndAppendResourceInfo(Class<?> clazz,
Method method,
JavaDocEntry docEntry,
RamlResource parentResource)
Extracts relevant info from a Java method and converts it into a RAML resource
|
protected String |
extractExpectedMimeTypeFromMethod(Method method)
Checks the annotations and return type that the method returns and the mime it corresponds to
|
protected String |
extractMimeTypeFromMethod(Method method)
Checks the annotations and return type that the method returns and the mime it corresponds to
|
protected Map<String,RamlQueryParameter> |
extractQueryParameters(RamlActionType apiAction,
Method method,
Map<String,String> parameterComments)
Extracts parameters from a method call and attaches these with the comments extracted from the javadoc
|
protected Pair<String,RamlMimeType> |
extractRequestBody(Method method,
Map<String,String> parameterComments,
String comment,
List<ApiParameterMetadata> apiParameters)
Converts a method body into a request json schema and a mime type.
|
protected Map<String,RamlMimeType> |
extractRequestBodyFromMethod(RamlActionType apiAction,
Method method,
Map<String,String> parameterComments)
Extracts the TOs and other parameters from a method and will convert into JsonSchema for inclusion in the body
TODO refactor this code structure
|
protected abstract ApiParameterMetadata[] |
extractResourceIdParameter(Method method)
Queries the parameters in the Method and checks for an AjaxParameter Annotation with the resource Id flag enabled
|
RamlResource |
extractResourceInfo(Class<?> clazz)
Extracts class information from a (believe it or not) java class as well as the contained methods.
|
protected RamlResponse |
extractResponseFromMethod(Method method,
String responseComment)
Extracts the Response Body from a method in JsonSchema Format and embeds it into a response object based on the
defaultMediaType
|
protected abstract List<ApiParameterMetadata> |
getApiParameters(Method method,
boolean includeUrlParameters,
boolean includeNonUrlParameters)
Allows children to specify which parameters within a method should be included in API generation
|
protected abstract Map<RamlActionType,String> |
getHttpMethodAndName(Class<?> clazz,
Method method)
Extracts the http method (verb) as well as the name of the api call
|
protected abstract String |
getResourceName(Class<?> clazz)
Extracts the name of the resource that this class manages
|
protected abstract boolean |
isActionOnResourceWithoutCommand(Method method)
Checks is this api call is made directly on a resource without a trailing command in the URL.
|
protected abstract boolean |
isQueryParameter(Parameter param)
Allows children to specify whether a parameter should be included when generating query parameters for a method
|
void |
setJavaDocs(JavaDocExtractor javaDocs)
Update JavaDoc extractor
|
protected abstract boolean |
shouldAddMethodToApi(Method method)
Allows child Scanners to add their own logic on whether a method should be treated as an API or ignored
|
protected static final org.slf4j.Logger logger
protected static final Pattern IGNORE_METHOD_REGEX
protected static final String CSRF_HEADER
public static final String CATCH_ALL_MEDIA_TYPE
protected JavaDocExtractor javaDocs
protected String version
protected String defaultMediaType
public void setJavaDocs(JavaDocExtractor javaDocs)
javaDocs - The java doc extractor to use (if any)public static boolean doesActionTypeSupportRequestBody(RamlActionType target)
target - The target Verb to checkpublic static boolean doesActionTypeSupportMultipartMime(RamlActionType target)
target - The target Verb to checkprotected abstract boolean shouldAddMethodToApi(Method method)
method - The method to inspectprotected Map<String,RamlQueryParameter> extractQueryParameters(RamlActionType apiAction, Method method, Map<String,String> parameterComments)
apiAction - The Verb of the action containing these parametesmethod - The method to inspectparameterComments - The parameter comments associated with these parametersprotected abstract boolean isQueryParameter(Parameter param)
param - The the Parameter to be checkedprotected abstract List<ApiParameterMetadata> getApiParameters(Method method, boolean includeUrlParameters, boolean includeNonUrlParameters)
method - The method to inspectincludeUrlParameters - If true this will include URL parametersincludeNonUrlParameters - If true this will include query and body paramsprotected Map<String,RamlMimeType> extractRequestBodyFromMethod(RamlActionType apiAction, Method method, Map<String,String> parameterComments)
apiAction - The Verb of the action to be addedmethod - The method to be inspectedparameterComments - The parameter comments associated with these parametersprotected Pair<String,RamlMimeType> extractRequestBody(Method method, Map<String,String> parameterComments, String comment, List<ApiParameterMetadata> apiParameters)
method - The method to be used to get the request objectparameterComments - Associated JavaDoc for Parameters (if any)comment - Main Method Javadoc Comment (if any)apiParameters - The Parameters identifed from this methodprotected abstract void addHeadersForMethod(RamlAction action, RamlActionType actionType, Method method)
action - The action to be modifiedactionType - The verb of the Actionmethod - The method to inspect for headersprotected abstract ApiParameterMetadata[] extractResourceIdParameter(Method method)
method - The Method to be inspectedprotected abstract Map<RamlActionType,String> getHttpMethodAndName(Class<?> clazz, Method method)
clazz - The controller classmethod - The Method to inspectprotected abstract void extractAndAppendResourceInfo(Class<?> clazz, Method method, JavaDocEntry docEntry, RamlResource parentResource)
clazz - The controller classmethod - The Java method to introspectdocEntry - The associated JavaDoc (may be null)parentResource - The Resource which contains this methodprotected abstract boolean isActionOnResourceWithoutCommand(Method method)
method - The method to checkprotected String extractMimeTypeFromMethod(Method method)
method - The method to inspectprotected String extractExpectedMimeTypeFromMethod(Method method)
method - The method to inspectprotected RamlResponse extractResponseFromMethod(Method method, String responseComment)
method - The method to inspectresponseComment - The JavaDoc (if any) for this responsepublic RamlResource extractResourceInfo(Class<?> clazz)
clazz - The Class to be inspectedCopyright © 2017. All rights reserved.