@ -52,16 +52,14 @@ import java.util.*;
public class AnnotationProcessor {
public class AnnotationProcessor {
public static final String WILD_CARD = "/*" ;
private static final Log log = LogFactory . getLog ( AnnotationProcessor . class ) ;
private static final Log log = LogFactory . getLog ( AnnotationProcessor . class ) ;
private static final String AUTH_TYPE = "Application & Application User" ;
private static final String AUTH_TYPE = "Application & Application User" ;
private static final String STRING_ARR = "string_arr" ;
private static final String STRING_ARR = "string_arr" ;
private static final String STRING = "string" ;
private static final String STRING = "string" ;
private static final String PACKAGE_ORG_APACHE = "org.apache" ;
private static final String PACKAGE_ORG_APACHE = "org.apache" ;
private static final String PACKAGE_ORG_CODEHAUS = "org.codehaus" ;
private static final String PACKAGE_ORG_CODEHAUS = "org.codehaus" ;
private static final String PACKAGE_ORG_SPRINGFRAMEWORK = "org.springframework" ;
private static final String PACKAGE_ORG_SPRINGFRAMEWORK = "org.springframework" ;
public static final String WILD_CARD = "/*" ;
private static final String SWAGGER_ANNOTATIONS_INFO = "info" ;
private static final String SWAGGER_ANNOTATIONS_INFO = "info" ;
private static final String SWAGGER_ANNOTATIONS_TAGS = "tags" ;
private static final String SWAGGER_ANNOTATIONS_TAGS = "tags" ;
private static final String SWAGGER_ANNOTATIONS_EXTENSIONS = "extensions" ;
private static final String SWAGGER_ANNOTATIONS_EXTENSIONS = "extensions" ;
@ -73,6 +71,9 @@ public class AnnotationProcessor {
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_ROLES = "roles" ;
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_ROLES = "roles" ;
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_VERSION = "version" ;
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_VERSION = "version" ;
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_CONTEXT = "context" ;
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_CONTEXT = "context" ;
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_API_DOCUMENTATION_NAME = "apiDocumentationName" ;
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_API_DOCUMENTATION_SUMMARY = "apiDocumentationSummary" ;
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_API_DOCUMENTATION_SOURCE_FILE = "apiDocumentationSourceFile" ;
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_ENDPOINT_TYPE = "endpointType" ;
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_ENDPOINT_TYPE = "endpointType" ;
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_IN_SEQUENCE_NAME = "inSequenceName" ;
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_IN_SEQUENCE_NAME = "inSequenceName" ;
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_IN_SEQUENCE_CONFIG = "inSequenceConfig" ;
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_IN_SEQUENCE_CONFIG = "inSequenceConfig" ;
@ -132,6 +133,26 @@ public class AnnotationProcessor {
}
}
}
}
/ * *
* Find the URL pointing to "/WEB-INF/classes" This method may not work in conjunction with IteratorFactory
* if your servlet container does not extract the / WEB - INF / classes into a real file - based directory
*
* @param servletContext
* @return null if cannot determin / WEB - INF / classes
* /
private static URL findWebInfClassesPath ( ServletContext servletContext ) {
String path = servletContext . getRealPath ( "/WEB-INF/classes" ) ;
if ( path = = null ) return null ;
File fp = new File ( path ) ;
if ( fp . exists ( ) = = false ) return null ;
try {
URI uri = fp . toURI ( ) ;
return uri . toURL ( ) ;
} catch ( MalformedURLException e ) {
throw new RuntimeException ( e ) ;
}
}
public Set < String > scanStandardContext ( String className ) throws IOException {
public Set < String > scanStandardContext ( String className ) throws IOException {
ExtendedAnnotationDB db = new ExtendedAnnotationDB ( ) ;
ExtendedAnnotationDB db = new ExtendedAnnotationDB ( ) ;
db . addIgnoredPackages ( PACKAGE_ORG_APACHE ) ;
db . addIgnoredPackages ( PACKAGE_ORG_APACHE ) ;
@ -369,7 +390,7 @@ public class AnnotationProcessor {
* Iterate API annotation and build API Configuration
* Iterate API annotation and build API Configuration
*
*
* @param annotation reading @SwaggerDefinition annotation
* @param annotation reading @SwaggerDefinition annotation
* @return APIResourceConfiguration which compose with an API information which has its name , context , version , and tags
* @return APIResourceConfiguration which compose with an API information which has its name , context , version , api - documentation , and tags
* @throws Throwable
* @throws Throwable
* /
* /
private APIResourceConfiguration processAPIAnnotation ( Annotation annotation ) throws Throwable {
private APIResourceConfiguration processAPIAnnotation ( Annotation annotation ) throws Throwable {
@ -411,6 +432,18 @@ public class AnnotationProcessor {
if ( "" . equals ( value ) ) return null ;
if ( "" . equals ( value ) ) return null ;
apiResourceConfig . setContext ( value ) ;
apiResourceConfig . setContext ( value ) ;
break ;
break ;
case SWAGGER_ANNOTATIONS_PROPERTIES_API_DOCUMENTATION_NAME :
if ( "" . equals ( value ) ) return null ;
apiResourceConfig . setApiDocumentationName ( value ) ;
break ;
case SWAGGER_ANNOTATIONS_PROPERTIES_API_DOCUMENTATION_SUMMARY :
if ( "" . equals ( value ) ) return null ;
apiResourceConfig . setApiDocumentationSummary ( value ) ;
break ;
case SWAGGER_ANNOTATIONS_PROPERTIES_API_DOCUMENTATION_SOURCE_FILE :
if ( "" . equals ( value ) ) return null ;
apiResourceConfig . setApiDocumentationSourceFile ( value ) ;
break ;
case SWAGGER_ANNOTATIONS_PROPERTIES_ENDPOINT_TYPE :
case SWAGGER_ANNOTATIONS_PROPERTIES_ENDPOINT_TYPE :
if ( "" . equals ( value ) )
if ( "" . equals ( value ) )
return null ;
return null ;
@ -478,30 +511,6 @@ public class AnnotationProcessor {
}
}
}
}
/ * *
* Find the URL pointing to "/WEB-INF/classes" This method may not work in conjunction with IteratorFactory
* if your servlet container does not extract the / WEB - INF / classes into a real file - based directory
*
* @param servletContext
* @return null if cannot determin / WEB - INF / classes
* /
private static URL findWebInfClassesPath ( ServletContext servletContext )
{
String path = servletContext . getRealPath ( "/WEB-INF/classes" ) ;
if ( path = = null ) return null ;
File fp = new File ( path ) ;
if ( fp . exists ( ) = = false ) return null ;
try
{
URI uri = fp . toURI ( ) ;
return uri . toURL ( ) ;
}
catch ( MalformedURLException e )
{
throw new RuntimeException ( e ) ;
}
}
private APIResource getAPiOperationExtensions ( Annotation currentMethod , APIResource apiResource ) throws Throwable {
private APIResource getAPiOperationExtensions ( Annotation currentMethod , APIResource apiResource ) throws Throwable {
InvocationHandler methodHandler = Proxy . getInvocationHandler ( currentMethod ) ;
InvocationHandler methodHandler = Proxy . getInvocationHandler ( currentMethod ) ;
Annotation [ ] extensions = ( Annotation [ ] ) methodHandler . invoke ( currentMethod ,
Annotation [ ] extensions = ( Annotation [ ] ) methodHandler . invoke ( currentMethod ,