Swagger integration with multiple query parameters in Scala Play Framework

Viewed 189

In simple Play Framework 2.8 REST Api Swagger support has been implemented using library sbt-play-swagger from here. plugins.sbt file:

addSbtPlugin("com.iheart" % "sbt-play-swagger" % "0.10.4-PLAY2.8")

build.sbt file:

  lazy val root = (project in file("."))
  .enablePlugins(PlayService, PlayLayoutPlugin, Common, PlayScala, SwaggerPlugin)
  .settings(
    name := "rest-api"
    scalaVersion := "2.12.8",
    libraryDependencies ++= Seq(
      guice,
      "org.joda" % "joda-convert" % "2.2.1",
      "net.logstash.logback" % "logstash-logback-encoder" % "6.2",
      "io.lemonlabs" %% "scala-uri" % "1.5.1",
      "net.codingwell" %% "scala-guice" % "4.2.6",
      "org.scalatestplus.play" %% "scalatestplus-play" % "5.1.0" % Test,
      "org.webjars" % "swagger-ui" % "3.43.0"
    ),
    scalacOptions ++= Seq(
      "-feature",
      "-deprecation",
      "-Xfatal-warnings"
    ),
    swaggerDomainNameSpaces := Seq("application.models")
  )

Query may handle multiple optional parameters, for such case "CarsSearch" case class has been defined with query string binders.

The problem is that swagger displays just one input string as parameter (as visible on printscreen), it looks like it does not know how to handle case class in such situation: enter image description here

How to make it working with multiple required and optional parameters like here: enter image description here

0 Answers
Related