Skip to content

Commit

Permalink
Merge pull request Yelp#145 from agologan/master
Browse files Browse the repository at this point in the history
  • Loading branch information
cortinico authored Nov 21, 2020
2 parents 54394ee + a7ef162 commit 8b24632
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{#isQueryParam}}@retrofit2.http.Query("{{baseName}}") {{#collectionFormat}}{{^isCollectionFormatMulti}}@{{{collectionFormat.toUpperCase}}} {{/isCollectionFormatMulti}}{{/collectionFormat}}{{paramName}}: {{{dataType}}}{{/isQueryParam}}
{{#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
Expand Up @@ -116,11 +116,11 @@ interface ResourceApi {
)
@GET("/symbols/in/parameter/name")
fun getSymbolsInParameterName(
@retrofit2.http.Query("parameter") parameter: String?,
@retrofit2.http.Query("brackets[]") brackets: String?,
@retrofit2.http.Query("brackets[withText]") bracketsWithText: String?,
@retrofit2.http.Query("dot.") dot: String?,
@retrofit2.http.Query("dot.withText") dotWithText: String?
@retrofit2.http.Query("parameter") parameter: String? = null,
@retrofit2.http.Query("brackets[]") brackets: String? = null,
@retrofit2.http.Query("brackets[withText]") bracketsWithText: String? = null,
@retrofit2.http.Query("dot.") dot: String? = null,
@retrofit2.http.Query("dot.withText") dotWithText: String? = null
): Completable
/**
* The endpoint is owned by junittests service owner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.yelp.codegen.generatecodesamples
import com.yelp.codegen.generatecodesamples.apis.ResourceApi
import com.yelp.codegen.generatecodesamples.tools.MockServerApiRule
import okhttp3.mockwebserver.MockResponse
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Rule
Expand Down Expand Up @@ -36,4 +37,22 @@ class ValidParameterTest {
assertTrue("dot.=testDot" in requestPath)
assertTrue("dot.withText=testDotWithText" in requestPath)
}

@Test
fun optionalParameters() {
mockServerRule.server.enqueue(MockResponse())

val defaultApi = mockServerRule.getApi<ResourceApi>()
val pet = defaultApi.getSymbolsInParameterName().blockingGet()

val requestPath = mockServerRule.server.takeRequest().path
assertNull(pet)

// No parameters should be present in the path
assertFalse("parameter=" in requestPath)
assertFalse("brackets%5B%5D=" in requestPath)
assertFalse("brackets%5BwithText%5D=" in requestPath)
assertFalse("dot.=" in requestPath)
assertFalse("dot.withText=" in requestPath)
}
}

0 comments on commit 8b24632

Please sign in to comment.