This repository was archived by the owner on Mar 16, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +32
-1
lines changed
main/groovy/com/github/hauner/openapi/core/writer/java
com/github/hauner/openapi/core/writer/java
io/openapiprocessor/core/model Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import com.github.hauner.openapi.core.framework.FrameworkAnnotations
2020import com.github.hauner.openapi.core.converter.ApiOptions
2121import com.github.hauner.openapi.core.model.Endpoint
2222import com.github.hauner.openapi.core.model.Interface
23+ import com.github.hauner.openapi.core.model.parameters.AdditionalParameter
2324import io.openapiprocessor.core.writer.java.DefaultImportFilter
2425import io.openapiprocessor.core.writer.java.ImportFilter
2526
@@ -78,6 +79,10 @@ class InterfaceWriter {
7879 imports. add (annotations. getAnnotation (p). fullyQualifiedName)
7980 }
8081
82+ if (p instanceof AdditionalParameter && p. hasAdditionalAnnotation ()) {
83+ imports. addAll (p. annotationDataType. imports)
84+ }
85+
8186 imports. addAll (p. dataTypeImports)
8287 }
8388
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ import com.github.hauner.openapi.core.model.HttpMethod
2525import com.github.hauner.openapi.core.model.Interface
2626import com.github.hauner.openapi.core.model.RequestBody
2727import com.github.hauner.openapi.core.model.Response
28+ import com.github.hauner.openapi.core.model.datatypes.AnnotationDataType
2829import com.github.hauner.openapi.core.model.datatypes.MappedDataType
2930import com.github.hauner.openapi.core.model.datatypes.NoneDataType
3031import com.github.hauner.openapi.core.model.datatypes.ObjectDataType
@@ -219,6 +220,31 @@ import model.Foo;
219220""" )
220221 }
221222
223+ void " writes additional parameter annotation import" () {
224+ // annotations.getAnnotation (_) >> new FrameworkAnnotation(name: 'Parameter', pkg: 'annotation')
225+
226+ def itf = intrface (' Foo' ) {
227+ endpoint (' /foo' ) {
228+ parameters {
229+ add {
230+ name (' bar' )
231+ type (new StringDataType ())
232+ annotation (new AnnotationDataType (pkg : ' bar' , type : ' Bar' , parameters : ' ()' ))
233+ }
234+ }
235+ }
236+ }
237+
238+ when :
239+ writer. write (target, itf)
240+
241+ then :
242+ def result = extractImports (target. toString ())
243+ result. contains(""" \
244+ import bar.Bar;
245+ """ )
246+ }
247+
222248 void " writes request body annotation import" () {
223249 annotations. getAnnotation (_) >> new FrameworkAnnotation (name : ' Body' , pkg : ' annotation' )
224250
Original file line number Diff line number Diff line change @@ -204,7 +204,7 @@ class ParametersBuilder {
204204 parameters. add (parameter)
205205 }
206206
207- void add (@DelegatesTo (strategy = Closure .DELEGATE_ONLY , value = QueryParameterBuilder ) Closure init ) {
207+ void add (@DelegatesTo (strategy = Closure .DELEGATE_ONLY , value = AddParameterBuilder ) Closure init ) {
208208 def builder = new AddParameterBuilder ()
209209 def code = init. rehydrate (builder, this , this )
210210 code. resolveStrategy = Closure . DELEGATE_ONLY
You can’t perform that action at this time.
0 commit comments