Skip to content

Commit 013c19e

Browse files
committed
Merge pull request #251 from earldouglas/not-so-required
Set param as 'required' iff required, else set as 'optional'
2 parents b4d3611 + 61c04dd commit 013c19e

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
@@ -143,16 +143,17 @@ class Codegen(config: CodegenConfig) {
143143
case _ =>
144144
}
145145

146-
if (!param.required) {
146+
if (param.required) {
147+
params += "required" -> "true"
148+
} else {
147149
params += "optional" -> "true"
148150
}
149151
param.paramType match {
150152
case "body" => {
151153
params += "paramName" -> "body"
152154
params += "baseName" -> "body"
153-
param.required match {
154-
case true => params += "required" -> "true"
155-
case _ => bodyParamRequired = None
155+
if (!param.required) {
156+
bodyParamRequired = None
156157
}
157158

158159
bodyParam = Some("body")
@@ -167,19 +168,16 @@ class Codegen(config: CodegenConfig) {
167168
case "query" => {
168169
params += "paramName" -> config.toVarName(param.name)
169170
params += "baseName" -> param.name
170-
params += "required" -> param.required.toString
171171
queryParams += params.clone
172172
}
173173
case "header" => {
174174
params += "paramName" -> config.toVarName(param.name)
175175
params += "baseName" -> param.name
176-
params += "required" -> param.required.toString
177176
headerParams += params.clone
178177
}
179178
case "form" => {
180179
params += "paramName" -> config.toVarName(param.name)
181180
params += "baseName" -> param.name
182-
params += "required" -> param.required.toString
183181
formParams += params.clone
184182
}
185183
case x @ _ => throw new Exception("Unknown parameter type: " + x)

0 commit comments

Comments
 (0)