@ -53,7 +53,6 @@ import java.util.*;
public class AnnotationProcessor {
public class AnnotationProcessor {
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" ;
@ -61,7 +60,6 @@ public class AnnotationProcessor {
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 = "/*" ;
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" ;
@ -131,7 +132,6 @@ public class AnnotationProcessor {
log . error ( "An error has occurred while loading classes " , e ) ;
log . error ( "An error has occurred while loading classes " , 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 +369,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 +411,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 ;
@ -485,19 +497,15 @@ public class AnnotationProcessor {
* @param servletContext
* @param servletContext
* @return null if cannot determin / WEB - INF / classes
* @return null if cannot determin / WEB - INF / classes
* /
* /
private static URL findWebInfClassesPath ( ServletContext servletContext )
private static URL findWebInfClassesPath ( ServletContext servletContext ) {
{
String path = servletContext . getRealPath ( "/WEB-INF/classes" ) ;
String path = servletContext . getRealPath ( "/WEB-INF/classes" ) ;
if ( path = = null ) return null ;
if ( path = = null ) return null ;
File fp = new File ( path ) ;
File fp = new File ( path ) ;
if ( fp . exists ( ) = = false ) return null ;
if ( fp . exists ( ) = = false ) return null ;
try
try {
{
URI uri = fp . toURI ( ) ;
URI uri = fp . toURI ( ) ;
return uri . toURL ( ) ;
return uri . toURL ( ) ;
}
} catch ( MalformedURLException e ) {
catch ( MalformedURLException e )
{
throw new RuntimeException ( e ) ;
throw new RuntimeException ( e ) ;
}
}
}
}