-
-
Save kciesielski/0cf4fecf0aa664359d00 to your computer and use it in GitHub Desktop.
Simple POST definition in Swagger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ExampleServlet(val swagger: Swagger) extends ScalatraServlet | |
with ExampleServletSwaggerDefinition with JacksonJsonSupport with JValueResult { | |
// ... | |
post("/", operation(addItemOperation)) { | |
val newItemRequest = parsedBody.extract[NewItemRequest] | |
ExampleItemDetails("new-item-id", newItemRequest.name, "product", Owner(1, "Owner name", true), new Date()) | |
} | |
// ... | |
} | |
trait ExampleServletSwaggerDefinition extends SwaggerSupport { | |
// ... | |
val addItemOperation = apiOperation[ExampleItemDetails]("addNewItem") | |
.parameter(bodyParam[NewItemRequest]("newItem").description("New item definition").required) | |
.summary("Creates a new item and returns its details") | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment