Skip to content

Commit

Permalink
dave - drawing out the JSON modesl
Browse files Browse the repository at this point in the history
  • Loading branch information
david denton committed Mar 28, 2015
1 parent 300e328 commit 9a9941e
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 48 deletions.
Expand Up @@ -48,15 +48,19 @@ class Swagger2dot0Json private(apiInfo: ApiInfo) extends Renderer {
}

def apply(mr: Seq[ModuleRoute]): JsonRootNode = {
val paths = mr
val pathFields: List[Field] = mr
.groupBy(_.toString)
.map { case (path, routes) => path -> obj(routes.map(a => render(a)._1))}.toSeq
.foldLeft((List[Field](), List[Field]())) {
case ((memoFields, memoDefinitions), (path, routes)) =>
val field: Field = path -> obj(routes.map(a => render(a)._1))
(field :: memoFields, memoDefinitions)
}._1

obj(
"swagger" -> string("2.0"),
"info" -> render(apiInfo),
"basePath" -> string("/"),
"paths" -> obj(paths),
"paths" -> obj(pathFields),
"definitions" -> obj()
)
}
Expand Down
Expand Up @@ -7,6 +7,50 @@
},
"basePath": "/",
"paths": {
"/basepath/welcome/{firstName}/bertrand/{secondName}": {
"get": {
"tags": [
"/basepath"
],
"summary": null,
"produces": [],
"consumes": [],
"parameters": [
{
"in": "query",
"name": "query",
"description": "description of the query",
"required": true,
"type": "boolean"
},
{
"in": "path",
"name": "firstName",
"description": null,
"required": true,
"type": "string"
},
{
"in": "path",
"name": "bertrand",
"description": null,
"required": true,
"type": "string"
},
{
"in": "path",
"name": "secondName",
"description": null,
"required": true,
"type": "string"
}
],
"responses": {},
"security": [
{}
]
}
},
"/basepath/echo/{message}": {
"post": {
"tags": [
Expand Down Expand Up @@ -80,51 +124,7 @@
{}
]
}
},
"/basepath/welcome/{firstName}/bertrand/{secondName}": {
"get": {
"tags": [
"/basepath"
],
"summary": null,
"produces": [],
"consumes": [],
"parameters": [
{
"in": "query",
"name": "query",
"description": "description of the query",
"required": true,
"type": "boolean"
},
{
"in": "path",
"name": "firstName",
"description": null,
"required": true,
"type": "string"
},
{
"in": "path",
"name": "bertrand",
"description": null,
"required": true,
"type": "string"
},
{
"in": "path",
"name": "secondName",
"description": null,
"required": true,
"type": "string"
}
],
"responses": {},
"security": [
{}
]
}
}
},
"definitions": {}
}
}

0 comments on commit 9a9941e

Please sign in to comment.