public class SpringMvcResourceParser extends ResourceParser
| Modifier and Type | Field and Description |
|---|---|
protected static org.slf4j.Logger |
logger |
protected boolean |
restrictOnMediaType
IF this is set to true, we will only parse methods that consume, produce or accept the requested defaultMediaType
|
CATCH_ALL_MEDIA_TYPE, CSRF_HEADER, defaultMediaType, IGNORE_METHOD_REGEX, javaDocs, version| Constructor and Description |
|---|
SpringMvcResourceParser(File path,
String version,
String defaultMediaType,
boolean restrictOnMediaType) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addHeadersForMethod(RamlAction action,
RamlActionType actionType,
Method method)
Allows children to add common headers to API methods (eg CSRF, Authorization)
|
protected 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)
Check for consumes annotation first.
|
protected String |
extractMimeTypeFromMethod(Method method)
Check for produces annotation first.
|
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 ApiParameterMetadata[] |
extractResourceIdParameter(Method method)
Queries the parameters in the Method and checks for an AjaxParameter Annotation with the resource Id flag enabled
|
protected 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 Map<RamlActionType,String> |
getHttpMethodAndName(Class<?> clazz,
Method method)
Extracts the http method (verb) as well as the name of the api call
|
protected String |
getParameterName(String preferredOption,
String fallback) |
protected Map<String,String> |
getPathDescriptionsForMethod(Method method)
Checks for instances of @Description annotations in
|
protected String |
getResourceName(Class<?> clazz)
Extracts the name of the resource that this class manages
|
protected boolean |
isActionOnResourceWithoutCommand(Method method)
Checks is this api call is made directly on a resource without a trailing command in the URL.
|
protected boolean |
isNonPathParameter(Parameter param) |
protected boolean |
isParameter(Parameter param) |
protected boolean |
isPathParameter(Parameter param) |
protected boolean |
isQueryParameter(Parameter param)
Allows children to specify whether a parameter should be included when generating query parameters for a method
|
protected 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 boolean |
shouldAddParameter(Parameter param)
Checks if a parameter has any metadata that has been attached using the RequestParam data which identifies it as
an API request parameter
|
doesActionTypeSupportMultipartMime, doesActionTypeSupportRequestBody, extractQueryParameters, extractRequestBodyFromMethod, extractResourceInfo, extractResponseFromMethod, setJavaDocsprotected static final org.slf4j.Logger logger
protected boolean restrictOnMediaType
protected Pair<String,RamlMimeType> extractRequestBody(Method method, Map<String,String> parameterComments, String comment, List<ApiParameterMetadata> apiParameters)
ResourceParserextractRequestBody in class ResourceParsermethod - 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 String extractMimeTypeFromMethod(Method method)
extractMimeTypeFromMethod in class ResourceParsermethod - The method to inspectprotected String extractExpectedMimeTypeFromMethod(Method method)
extractExpectedMimeTypeFromMethod in class ResourceParsermethod - The method to inspectprotected boolean shouldAddMethodToApi(Method method)
ResourceParsershouldAddMethodToApi in class ResourceParsermethod - The method to inspectprotected boolean shouldAddParameter(Parameter param)
param - The Parameter to be checkedprotected List<ApiParameterMetadata> getApiParameters(Method method, boolean includeUrlParameters, boolean includeNonUrlParameters)
ResourceParsergetApiParameters in class ResourceParsermethod - The method to inspectincludeUrlParameters - If true this will include URL parametersincludeNonUrlParameters - If true this will include query and body paramsprotected boolean isParameter(Parameter param)
protected boolean isPathParameter(Parameter param)
protected boolean isNonPathParameter(Parameter param)
protected boolean isQueryParameter(Parameter param)
ResourceParserisQueryParameter in class ResourceParserparam - The the Parameter to be checkedprotected Map<String,String> getPathDescriptionsForMethod(Method method)
method - The method to Inspectprotected ApiParameterMetadata[] extractResourceIdParameter(Method method)
ResourceParserextractResourceIdParameter in class ResourceParsermethod - The Method to be inspectedprotected Map<RamlActionType,String> getHttpMethodAndName(Class<?> clazz, Method method)
ResourceParsergetHttpMethodAndName in class ResourceParserclazz - The controller classmethod - The Method to inspectprotected boolean isActionOnResourceWithoutCommand(Method method)
ResourceParserisActionOnResourceWithoutCommand in class ResourceParsermethod - The method to checkprotected String getResourceName(Class<?> clazz)
ResourceParsergetResourceName in class ResourceParserclazz - The Class to inspectprotected void extractAndAppendResourceInfo(Class<?> clazz, Method method, JavaDocEntry docEntry, RamlResource parentResource)
ResourceParserextractAndAppendResourceInfo in class ResourceParserclazz - The controller classmethod - The Java method to introspectdocEntry - The associated JavaDoc (may be null)parentResource - The Resource which contains this methodprotected void addHeadersForMethod(RamlAction action, RamlActionType actionType, Method method)
ResourceParseraddHeadersForMethod in class ResourceParseraction - The action to be modifiedactionType - The verb of the Actionmethod - The method to inspect for headersCopyright © 2017. All rights reserved.