File tree Expand file tree Collapse file tree 3 files changed +25
-6
lines changed
gradle-plugin/plugin/src/main/resources/kotlin/retrofit2
main/java/com/yelp/codegen/generatecodesamples/apis
test/java/com/yelp/codegen/generatecodesamples Expand file tree Collapse file tree 3 files changed +25
-6
lines changed Original file line number Diff line number Diff line change 1
- { {#isQueryParam} }@retrofit2.http.Query("{ {baseName} }") { {#collectionFormat} }{ {^isCollectionFormatMulti} }@{ {{collectionFormat.toUpperCase} }} { {/isCollectionFormatMulti} }{ {/collectionFormat} }{ {paramName} }: { {{dataType} }}{ {/isQueryParam} }
1
+ { {#isQueryParam} }@retrofit2.http.Query("{ {baseName} }") { {#collectionFormat} }{ {^isCollectionFormatMulti} }@{ {{collectionFormat.toUpperCase} }} { {/isCollectionFormatMulti} }{ {/collectionFormat} }{ {paramName} }: { {{dataType} }}{ {^required } } = null { {/required } } { { /isQueryParam} }
Original file line number Diff line number Diff line change @@ -116,11 +116,11 @@ interface ResourceApi {
116
116
)
117
117
@GET(" /symbols/in/parameter/name" )
118
118
fun getSymbolsInParameterName (
119
- @retrofit2.http.Query ("parameter") parameter : String? ,
120
- @retrofit2.http.Query ("brackets[]") brackets : String? ,
121
- @retrofit2.http.Query ("brackets[withText]") bracketsWithText : String? ,
122
- @retrofit2.http.Query ("dot.") dot : String? ,
123
- @retrofit2.http.Query ("dot.withText") dotWithText : String?
119
+ @retrofit2.http.Query ("parameter") parameter : String? = null ,
120
+ @retrofit2.http.Query ("brackets[]") brackets : String? = null ,
121
+ @retrofit2.http.Query ("brackets[withText]") bracketsWithText : String? = null ,
122
+ @retrofit2.http.Query ("dot.") dot : String? = null ,
123
+ @retrofit2.http.Query ("dot.withText") dotWithText : String? = null
124
124
): Completable
125
125
/* *
126
126
* The endpoint is owned by junittests service owner
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package com.yelp.codegen.generatecodesamples
3
3
import com.yelp.codegen.generatecodesamples.apis.ResourceApi
4
4
import com.yelp.codegen.generatecodesamples.tools.MockServerApiRule
5
5
import okhttp3.mockwebserver.MockResponse
6
+ import org.junit.Assert.assertFalse
6
7
import org.junit.Assert.assertNull
7
8
import org.junit.Assert.assertTrue
8
9
import org.junit.Rule
@@ -36,4 +37,22 @@ class ValidParameterTest {
36
37
assertTrue(" dot.=testDot" in requestPath)
37
38
assertTrue(" dot.withText=testDotWithText" in requestPath)
38
39
}
40
+
41
+ @Test
42
+ fun optionalParameters () {
43
+ mockServerRule.server.enqueue(MockResponse ())
44
+
45
+ val defaultApi = mockServerRule.getApi<ResourceApi >()
46
+ val pet = defaultApi.getSymbolsInParameterName().blockingGet()
47
+
48
+ val requestPath = mockServerRule.server.takeRequest().path
49
+ assertNull(pet)
50
+
51
+ // No parameters should be present in the path
52
+ assertFalse(" parameter=" in requestPath)
53
+ assertFalse(" brackets%5B%5D=" in requestPath)
54
+ assertFalse(" brackets%5BwithText%5D=" in requestPath)
55
+ assertFalse(" dot.=" in requestPath)
56
+ assertFalse(" dot.withText=" in requestPath)
57
+ }
39
58
}
You can’t perform that action at this time.
0 commit comments