Skip to content

Commit 92dae53

Browse files
Do not get a null value from an option if it is empty, but rather keep the None value. If a value is present it is converted to an Option[String]
1 parent 1770d10 commit 92dae53

4 files changed

Lines changed: 5 additions & 5 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
"{{baseName}}", {{#isContainer}}ArrayValues({{{paramName}}}{{#collectionFormat}}, {{collectionFormat.toUpperCase}}{{/collectionFormat}}){{/isContainer}}{{^isContainer}}{{{paramName}}}{{/isContainer}}{{#required}}.toString{{/required}}{{^required}}.map(_.toString()).getOrElse(null){{/required}}
1+
"{{baseName}}", {{#isContainer}}ArrayValues({{{paramName}}}{{#collectionFormat}}, {{collectionFormat.toUpperCase}}{{/collectionFormat}}){{/isContainer}}{{^isContainer}}{{{paramName}}}{{/isContainer}}{{#required}}.toString{{/required}}{{^required}}.map(_.toString()){{/required}}

modules/openapi-generator/src/test/java/org/openapitools/codegen/scala/SttpCodegenTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,11 @@ public void headerSerialization() throws IOException {
139139
Path path = Paths.get(outputPath + "/src/main/scala/org/openapitools/client/api/DefaultApi.scala");
140140
assertFileContains(path, ".method(Method.GET, uri\"$baseUrl/ping\")\n");
141141
assertFileContains(path, "xOptionalHeader: Option[String] = None");
142-
assertFileContains(path, ".header(\"X-Optional-Header\", xOptionalHeader.map(_.toString()).getOrElse(null))");
142+
assertFileContains(path, ".header(\"X-Optional-Header\", xOptionalHeader.map(_.toString()))");
143143
assertFileContains(path, "xRequiredHeader: String");
144144
assertFileContains(path, ".header(\"X-Required-Header\", xRequiredHeader.toString)");
145145
assertFileContains(path, "xOptionalSchemaHeader: Option[UUID] = None");
146-
assertFileContains(path, ".header(\"X-Optional-Schema-Header\", xOptionalSchemaHeader.map(_.toString()).getOrElse(null))");
146+
assertFileContains(path, ".header(\"X-Optional-Schema-Header\", xOptionalSchemaHeader.map(_.toString()))");
147147
assertFileContains(path, "xRequiredSchemaHeader: UUID");
148148
assertFileContains(path, ".header(\"X-Required-Schema-Header\", xRequiredSchemaHeader.toString)");
149149
}

samples/client/petstore/scala-sttp-circe/src/main/scala/org/openapitools/client/api/PetApi.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class PetApi(baseUrl: String) {
5555
basicRequest
5656
.method(Method.DELETE, uri"$baseUrl/pet/${petId}")
5757
.contentType("application/json")
58-
.header("api_key", apiKey.map(_.toString()).getOrElse(null))
58+
.header("api_key", apiKey.map(_.toString()))
5959
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
6060

6161
/**

samples/client/petstore/scala-sttp/src/main/scala/org/openapitools/client/api/PetApi.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class PetApi(baseUrl: String) {
5555
basicRequest
5656
.method(Method.DELETE, uri"$baseUrl/pet/${petId}")
5757
.contentType("application/json")
58-
.header("api_key", apiKey.map(_.toString()).getOrElse(null))
58+
.header("api_key", apiKey.map(_.toString()))
5959
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
6060

6161
/**

0 commit comments

Comments
 (0)