Open Damon-V79 opened 7 years ago
Hello!
We want to use optional parameters in an HTTP request, as it described here for pagination. "offset" and "limit" must be optional parameters.
This pull-request adds processing support for not required query parameter (i.e. /items?id=###).
Swagger:
paths: # dogs /dogs: get: operationId: getDogs produces: - application/json parameters: - name: limit in: query required: false type: integer format: int32 - name: offset in: query required: false type: integer format: int32 responses: 200: schema: $ref: "#/definitions/Dogs" /just_test: get: operationId: justTest produces: - application/json parameters: - name: default in: query type: integer format: int32 - name: required in: query required: true type: integer format: int32 - name: optional in: query required: false type: integer format: int32 responses: 200: schema: $ref: "#/definitions/Dogs"
Old Scala code:
trait DogsApi extends Service { def getDogs(limit: Int, offset: Int): ServiceCall[akka.NotUsed, Dogs] def justTest(default: Int, required: Int, optional: Int): ServiceCall[akka.NotUsed, Dogs] final override def descriptor: Descriptor = { named("dogs").withCalls( restCall(Method.GET, "/api/v1.0/dogs?limit&offset", getDogs _), restCall(Method.GET, "/api/v1.0/just_test?default&optional&required", justTest _) ).withAutoAcl(true) } }
New Scala code:
trait DogsApi extends Service { def getDogs(limit: Option[Int], offset: Option[Int]): ServiceCall[akka.NotUsed, Dogs] def justTest(default: Option[Int], required: Int, optional: Option[Int]): ServiceCall[akka.NotUsed, Dogs] final override def descriptor: Descriptor = { named("dogs").withCalls( restCall(Method.GET, "/api/v1.0/dogs?limit&offset", getDogs _), restCall(Method.GET, "/api/v1.0/just_test?default&optional&required", justTest _) ).withAutoAcl(true) } }
Test project.
Hello!
We want to use optional parameters in an HTTP request, as it described here for pagination. "offset" and "limit" must be optional parameters.
This pull-request adds processing support for not required query parameter (i.e. /items?id=###).
Swagger:
Old Scala code:
New Scala code:
Test project.