Skip to content

Commit 61c04dd

Browse files
committed
Set param as 'required' iff required, else set as 'optional'
1 parent f4b2d13 commit 61c04dd

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/main/scala/com/wordnik/swagger/codegen/Codegen.scala

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -263,16 +263,17 @@ class Codegen(config: CodegenConfig) {
263263
case _ =>
264264
}
265265

266-
if (!param.required) {
266+
if (param.required) {
267+
params += "required" -> "true"
268+
} else {
267269
params += "optional" -> "true"
268270
}
269271
param.paramType match {
270272
case "body" => {
271273
params += "paramName" -> "body"
272274
params += "baseName" -> "body"
273-
param.required match {
274-
case true => params += "required" -> "true"
275-
case _ => bodyParamRequired = None
275+
if (!param.required) {
276+
bodyParamRequired = None
276277
}
277278

278279
bodyParam = Some("body")
@@ -287,19 +288,16 @@ class Codegen(config: CodegenConfig) {
287288
case "query" => {
288289
params += "paramName" -> config.toVarName(param.name)
289290
params += "baseName" -> param.name
290-
params += "required" -> param.required.toString
291291
queryParams += params.clone
292292
}
293293
case "header" => {
294294
params += "paramName" -> config.toVarName(param.name)
295295
params += "baseName" -> param.name
296-
params += "required" -> param.required.toString
297296
headerParams += params.clone
298297
}
299298
case "form" => {
300299
params += "paramName" -> config.toVarName(param.name)
301300
params += "baseName" -> param.name
302-
params += "required" -> param.required.toString
303301
formParams += params.clone
304302
}
305303
case x @ _ => throw new Exception("Unknown parameter type: " + x)

0 commit comments

Comments
 (0)