-
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.
feat(spring): support SpringDoc
@ParameterObject
(#1823)
* feat(springdoc-parameter-object): support with jakarta-query-param * Remove need for Jakarta annotation for Spring param bean on GET methods Signed-off-by: Michael Edgar <[email protected]> * Resolve some warnings in Spring extension Signed-off-by: Michael Edgar <[email protected]> --------- Signed-off-by: Michael Edgar <[email protected]> Co-authored-by: Diego Ramp (u125015) <[email protected]> Co-authored-by: Michael Edgar <[email protected]>
- Loading branch information
1 parent
58824e2
commit 955121c
Showing
20 changed files
with
194 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
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
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
13 changes: 13 additions & 0 deletions
13
...spring/src/test/java/test/io/smallrye/openapi/runtime/scanner/entities/GreetingParam.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,13 @@ | ||
package test.io.smallrye.openapi.runtime.scanner.entities; | ||
|
||
public class GreetingParam { | ||
private final String name; | ||
|
||
public GreetingParam(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
} |
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
Oops, something went wrong.