-
Notifications
You must be signed in to change notification settings - Fork 15
Changing a post param to required causes generation error in model #52
Comments
is this the intended behavior? as |
This is indeed the expected behaviour. The snippet Do you think we should provide marker comments for the beginning and for the end of the code which won't be changed by the plugin despite changes in the specification? |
@slavaschmidt doesn't make sense to me yet; the snippet |
I guess I can wrap the name parameter that is no longer optional into an Option before passing it to the case class; however, that feels like a hack; Is that what was intended? |
and yes, definitely. Giving clearly documented / marked entry points to the developers will help with keeping play-swagger errors apart from developer errors. |
@okthatsneat Yes, you can wrap the parameter into the Option. The code will compile then. And actually, this would not be a hack in a real project. The action method expect YOU as a programmer to provide a logic with a return type |
I was able to get the new controller skeleton generated: for this the play application needs to be aborted, and the artefacts cleaned. The generated controller now reads import play.api.mvc.{Action, Controller}
import play.api.data.validation.Constraint
import de.zalando.play.controllers._
import PlayBodyParsing._
import PlayValidations._
package echo.yaml {
class EchoYaml extends EchoYamlBase {
val get = getAction {
???
} //////// EOF //////// getAction
val post = postAction {
input: (PostName, PostName) =>
val (name, year) = input
???
} //////// EOF //////// postAction
val getTest_pathById = getTest_pathByIdAction {
(id: String) =>
???
} //////// EOF //////// getTest_pathByIdAction
}
}
and the generated model package echo
package object yaml {
import java.util.Date
import java.io.File
type PostName = Option[String]
type `Test-pathIdGetId` = String
type PostResponses200 = Option[PostResponses200Opt]
case class PostResponses200Opt(name: PostName,
year: PostName
)
} if I now add to the name post param to required: true and reload in the browser, and implement all controller actions with dummy
which points me to the generated model case class that I have no control over, which still is implemented as
I would have expected it to re-generate with a correct type and signature for the exptected return type with regards to the now no longer optional parameter name. |
It seems for me, that you have a return type for If yes, then you expected to return something of that type from your controller, not a It is your responsibility as a programmer to return correct result from your business logic, and in this case it should be of type |
Won't fix |
steps to reproduce:
localhost:9000
required: true
to the post paramname
expected: required constraint rendered in swagger ui
got instead:
generated file at fault:
target/scala-2.11/routes/main/model/echo.yaml.scala
The text was updated successfully, but these errors were encountered: