Skip to content

Instantly share code, notes, and snippets.

@jonthegeek
Created May 12, 2022 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonthegeek/fa5efa04d598ae2a9fe04a7178133658 to your computer and use it in GitHub Desktop.
Save jonthegeek/fa5efa04d598ae2a9fe04a7178133658 to your computer and use it in GitHub Desktop.
The start of an openAPI Parser
api_spec <- jsonlite::read_json("R-raw/swagger.json")
# I never got to the point of actually using this here, but this is where it is.
base_path <- api_spec$servers[[1]]$url
methods <- tibble::enframe(
x = api_spec$paths,
name = "path"
) %>%
tidyr::unnest_wider(value) %>%
tidyr::pivot_longer(
get:put,
names_to = "http"
) %>%
dplyr::mutate(
http = toupper(http),
is_null = purrr::map_lgl(value, is.null)
) %>%
dplyr::filter(!is_null) %>%
dplyr::select(-is_null) %>%
tidyr::unnest_wider(
value
) %>%
dplyr::filter(is.na(deprecated) | !deprecated) %>%
dplyr::select(-deprecated)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment