Skip to content

Commit

Permalink
update to generate swagger docs for mounted routers
Browse files Browse the repository at this point in the history
  • Loading branch information
bradleyhd committed Jun 19, 2018
1 parent 095b537 commit 757a7f5
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion R/plumber.R
Expand Up @@ -532,7 +532,30 @@ plumber <- R6Class(
private$addFilterInternal(filter)
},
swaggerFile = function(){ #FIXME: test
endpoints <- prepareSwaggerEndpoints(self$endpoints)
endpoints <- self$endpoints

if (length(self$mounts) > 0){
for (path in names(self$mounts)){

mount <- self$mounts[[path]]
mount_endpoints <- mount$endpoints
path <- sub("[/]$", "", path)

if (length(mount_endpoints) > 0) {
mount_endpoints <- lapply(mount_endpoints, function(i){
i <- lapply(i, function(j){
subpath <- sub("^[/]", "", j$path)
j$path <- paste(path, subpath, sep="/")
j
})
i
})

endpoints <- c(endpoints, mount_endpoints)
}
}
}
endpoints <- prepareSwaggerEndpoints(endpoints)

# Extend the previously parsed settings with the endpoints
def <- modifyList(private$globalSettings, list(paths=endpoints))
Expand Down

0 comments on commit 757a7f5

Please sign in to comment.