Created
November 27, 2013 23:18
-
-
Save chronodm/7684748 to your computer and use it in GitHub Desktop.
Scalatra servlet with failing JSON serialization
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
package router | |
import service.BibService | |
import model.Bib | |
import org.scalatra.swagger.Swagger | |
import spray.json._ | |
import DefaultJsonProtocol._ | |
import format.ApiFormats._ | |
/** | |
* @version $Id$ $Rev: 223159 $ $Date: 2013-11-27 15:12:03 -0800 (Wed, 27 Nov 2013) $ | |
*/ | |
class BibRouter(config: { | |
val swagger: Swagger | |
val bibService: BibService | |
}) | |
extends RouterBase(config.swagger) { | |
protected def applicationDescription: String = "Bibliographic data API" | |
get("/", operation(apiOperation[List[Bib]]("getBibs") | |
summary "Get all bibs")) { | |
config.bibService.allBibs.toJson | |
} | |
get("/:id", operation(apiOperation[Bib]("getBib") | |
summary "Get a bib")) { | |
config.bibService.getBib(Integer.parseInt(params("id"))).toJson | |
} | |
get("/ids", operation(apiOperation[List[Int]]("allBibIds") | |
summary "Get all bib IDs")) { | |
config.bibService.allBibIds.toJson | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment