Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
}