Skip to content

Commit bc246e1

Browse files
committed
fix/improve annotations (#439)
1 parent ff41f46 commit bc246e1

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

src/main/kotlin/io/openapiprocessor/spring/processor/SpringFrameworkExchange.kt

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class SpringFrameworkExchange: FrameworkAnnotations {
3232
}
3333

3434
return Annotation(
35-
getExchangeAnnotationName("Http"),
35+
getServiceAnnotationName("Http"),
3636
linkedMapOf("method" to SimpleParameterValue(""""${httpMethod.toString().uppercase()}"""")))
3737
}
3838

@@ -77,33 +77,34 @@ class SpringFrameworkExchange: FrameworkAnnotations {
7777
}
7878
}
7979

80-
private const val EXCHANGE_ANNOTATION_PKG = "org.springframework.web.service.annotation"
80+
private fun getBindAnnotationName(name: String): String =
81+
"org.springframework.web.bind.annotation.${name}"
8182

82-
private fun getExchangeAnnotationName(methodName: String): String =
83-
"$EXCHANGE_ANNOTATION_PKG.${methodName}Exchange"
83+
private fun getServiceAnnotationName(methodName: String): String =
84+
"org.springframework.web.service.annotation.${methodName}Exchange"
8485

8586
private val EXCHANGE_ANNOTATIONS = hashMapOf(
86-
HttpMethod.DELETE to Annotation(getExchangeAnnotationName("Delete")),
87-
HttpMethod.GET to Annotation(getExchangeAnnotationName("Get")),
88-
HttpMethod.HEAD to Annotation(getExchangeAnnotationName("Http"),
89-
linkedMapOf("method" to SimpleParameterValue(""""HEAD""""))),
90-
HttpMethod.OPTIONS to Annotation(getExchangeAnnotationName("Http"),
87+
HttpMethod.DELETE to Annotation(getServiceAnnotationName("Delete")),
88+
HttpMethod.GET to Annotation(getServiceAnnotationName("Get")),
89+
HttpMethod.HEAD to Annotation(getServiceAnnotationName("Http"),
90+
linkedMapOf("method" to SimpleParameterValue(""""HEAD""""))),
91+
HttpMethod.OPTIONS to Annotation(getServiceAnnotationName("Http"),
9192
linkedMapOf("method" to SimpleParameterValue(""""OPTIONS""""))),
92-
HttpMethod.PATCH to Annotation(getExchangeAnnotationName("Patch")),
93-
HttpMethod.POST to Annotation(getExchangeAnnotationName("Post")),
94-
HttpMethod.PUT to Annotation(getExchangeAnnotationName("Put")),
95-
HttpMethod.TRACE to Annotation(getExchangeAnnotationName("Http"),
93+
HttpMethod.PATCH to Annotation(getServiceAnnotationName("Patch")),
94+
HttpMethod.POST to Annotation(getServiceAnnotationName("Post")),
95+
HttpMethod.PUT to Annotation(getServiceAnnotationName("Put")),
96+
HttpMethod.TRACE to Annotation(getServiceAnnotationName("Http"),
9697
linkedMapOf("method" to SimpleParameterValue(""""TRACE"""")))
9798
)
9899

99100
private val PARAMETER_ANNOTATIONS = hashMapOf(
100-
"query" to Annotation ("org.springframework.web.service.annotation.QueryParam"),
101-
"header" to Annotation ("org.springframework.web.service.annotation.Header"),
102-
"cookie" to Annotation ("org.springframework.web.service.annotation.Cookie"),
103-
"path" to Annotation ("org.springframework.web.service.annotation.PathVariable"),
104-
"multipart-param" to Annotation ("org.springframework.web.service.annotation.Part"),
105-
"multipart-part" to Annotation ("org.springframework.web.service.annotation.Part"),
106-
"body" to Annotation ("org.springframework.web.service.annotation.RequestBody")
101+
"query" to Annotation (getBindAnnotationName("RequestParam")),
102+
"header" to Annotation (getBindAnnotationName("RequestHeader")),
103+
"cookie" to Annotation (getBindAnnotationName("CookieValue")),
104+
"path" to Annotation (getBindAnnotationName("PathVariable")),
105+
"multipart-param" to Annotation (getBindAnnotationName("RequestParam")),
106+
"multipart-part" to Annotation (getBindAnnotationName("RequestPart")),
107+
"body" to Annotation (getBindAnnotationName("RequestBody"))
107108
)
108109

109110
private val UNKNOWN_ANNOTATION = Annotation("Unknown")

0 commit comments

Comments
 (0)