-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve some warnings in Spring extension
Signed-off-by: Michael Edgar <[email protected]>
- Loading branch information
Showing
12 changed files
with
67 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
extension-spring/src/main/java/io/smallrye/openapi/spring/SpringSupport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package io.smallrye.openapi.spring; | ||
|
||
import java.util.LinkedHashSet; | ||
import java.util.Set; | ||
|
||
import org.eclipse.microprofile.openapi.models.PathItem; | ||
import org.jboss.jandex.AnnotationInstance; | ||
import org.jboss.jandex.AnnotationValue; | ||
import org.jboss.jandex.DotName; | ||
import org.jboss.jandex.MethodInfo; | ||
|
||
class SpringSupport { | ||
|
||
private SpringSupport() { | ||
} | ||
|
||
static Set<PathItem.HttpMethod> getHttpMethods(MethodInfo methodInfo) { | ||
Set<PathItem.HttpMethod> methods = new LinkedHashSet<>(); | ||
|
||
// Try @XXXMapping annotations | ||
for (DotName validMethodAnnotations : SpringConstants.HTTP_METHODS) { | ||
if (methodInfo.hasAnnotation(validMethodAnnotations)) { | ||
String toHttpMethod = toHttpMethod(validMethodAnnotations); | ||
methods.add(PathItem.HttpMethod.valueOf(toHttpMethod)); | ||
} | ||
} | ||
|
||
// Try @RequestMapping | ||
if (methodInfo.hasAnnotation(SpringConstants.REQUEST_MAPPING)) { | ||
AnnotationInstance requestMappingAnnotation = methodInfo.annotation(SpringConstants.REQUEST_MAPPING); | ||
AnnotationValue methodValue = requestMappingAnnotation.value("method"); | ||
|
||
if (methodValue != null) { | ||
String[] enumArray = methodValue.asEnumArray(); | ||
for (String enumValue : enumArray) { | ||
if (enumValue != null) { | ||
methods.add(PathItem.HttpMethod.valueOf(enumValue.toUpperCase())); | ||
} | ||
} | ||
} else { | ||
// Default ? | ||
} | ||
} | ||
|
||
return methods; | ||
} | ||
|
||
private static String toHttpMethod(DotName dotname) { | ||
String className = dotname.withoutPackagePrefix(); | ||
className = className.replace("Mapping", ""); | ||
return className.toUpperCase(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters