#696 Fix #692, set openapi spec with file path

Open Bruno Tremblay meztez

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.

Showing 1 of 4 files from the diff.

@@ -887,9 +887,20 @@
Loading
887 887
    #' @param api This can be
888 888
    #'   * an OpenAPI Specification formatted list object
889 889
    #'   * a function that accepts the OpenAPI Specification autogenerated by `plumber` and returns a OpenAPI Specification formatted list object.
890 +
    #'   * a path to an OpenAPI Specification
890 891
    #'
891 892
    #'  The value returned will not be validated for OAS compatibility.
892 893
    setApiSpec = function(api = NULL) {
894 +
      if (is.character(api) && length(api) == 1 && file.exists(api)) {
895 +
        if (tools::file_ext(api) %in% c("yaml", "yml")) {
896 +
          if (!requireNamespace("yaml", quietly = TRUE)) {
897 +
            stop("yaml must be installed to read yaml format")
898 +
          }
899 +
          api <- yaml::read_yaml(api, eval.expr = FALSE)
900 +
        } else {
901 +
          api <- jsonlite::read_json(api, simplifyVector = TRUE)
902 +
        }
903 +
      }
893 904
      api_fun <-
894 905
        if (is.null(api)) {
895 906
          identity

Learn more Showing 4 files with coverage changes found.

Changes in R/parse-body.R
New
Loading file...
Changes in R/serializer.R
New
Loading file...
Changes in R/plumber.R
-2
+2
Loading file...
Changes in R/pr_set.R
-3
+3
Loading file...
Files Coverage
R 0.17% 80.40%
Project Totals (35 files) 80.40%
Loading