I have written an API endpoint using plumber. I'm using the @apiVersion tag in the comments for documentation purposes and would like to add the version as string to the JSON object my endpoint is returning:
#' @apiTitle My cool API
#' @apiDescription This API does something.
#' @apiVersion 0.1
#* @serializer unboxedJSON
#* @post /call_me
function() {
return(list(my_value = 42, api_version = "0.1"))
}
Is there a way to programmatically access the string in @apiVersion?
apiVersion info is stored in the router private global settings.
They are the last information to be read when parsing a plumber file so they are not available until after the parsing of the file is done.
This is one way to do it using the
apiSpec
directly.