demo_json |>
tibble::enframe(name = "api_id") |>
tidyr::unnest_longer(value, indices_include = FALSE) |>
tidyr::unnest_longer(value, indices_to = "version") |>
tidyr::unnest_wider(value)
#> # A tibble: 3 × 8
#> api_id added updated swaggerUrl swaggerYamlUrl openapiVer link version
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 apis.guru 2015… 2023-0… https://a… https://api.a… 3.0.0 http… 2.2.0
#> 2 fec.gov 2018… 2023-0… https://a… https://api.a… 3.0.0 http… 1.0
#> 3 googleapis.c… 2020… 2023-0… https://a… https://api.a… 3.0.0 http… v3
tidyr::unnest_auto()
#> # A tibble: 3 × 8
#> api_id .names added updated swaggerUrl swaggerYamlUrl openapiVer link
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 apis.guru 2.2.0 2015… 2023-0… https://a… https://api.a… 3.0.0 http…
#> 2 fec.gov 1.0 2018… 2023-0… https://a… https://api.a… 3.0.0 http…
#> 3 googleapis.co… v3 2020… 2023-0… https://a… https://api.a… 3.0.0 http…
tibblify::tibblify()
spec
argument
tibblify::guess_tspec()
JSON
(jsonlite::read_json()
)
openapi: 3.0.0 # Specification version number
info: # title, version, description, contact, license
servers: # One or more URLs + optional descriptions
tags: # Optional name, description, externalDocs of endpoint categories
externalDocs: # Optional url & description of additional documentation
security: # Optional list of named default security schemes
paths: # Endpoints of the API
webhooks: # Description of endpoints YOU can specify for API to SEND to
jsonSchemaDialect: # URI to extend components/schemas
x-whatever: # Extend with additional properties
components: # Reusable schemas, securitySchemes, reusable pieces of everything above
components:
schemas:
ApiVersion:
additionalProperties: false
properties:
added:
description: Timestamp when the version was added
format: date-time
type: string
link:
description: Link to the individual API entry for this API
format: url
type: string
openapiVer:
description: The value of the `openapi` or `swagger` property of the source definition
type: string
swaggerUrl:
description: URL to OpenAPI definition in JSON format
format: url
type: string
swaggerYamlUrl:
description: URL to OpenAPI definition in YAML format
format: url
type: string
updated:
description: Timestamp when the version was updated
format: date-time
type: string
required:
- added
- updated
- swaggerUrl
- swaggerYamlUrl
- openapiVer
type: object
tib_chr_datetime <- function(key, ..., required = TRUE) {
tibblify::tib_scalar(
key = key,
ptype = vctrs::new_datetime(tzone = "UTC"),
required = required,
ptype_inner = character(),
transform = \(x) as.POSIXct(x, format = "%Y-%m-%dT%H:%M:%OSZ", tz = "UTC"),
...
)
}
tspec_api_version <- tspec_row(
tib_chr_datetime("added"),
tib_chr_datetime("updated"),
tib_chr("openapiVer"),
tib_chr("swaggerUrl"),
tib_chr("swaggerYamlUrl"),
tib_chr("link", required = FALSE)
)
#> # A tibble: 1 × 7
#> version added updated openapiVer swaggerUrl
#> <chr> <dttm> <dttm> <chr> <chr>
#> 1 2.2.0 2015-11-26 17:52:26 2023-04-05 13:10:14 3.0.0 https://api.apis.g…
#> # ℹ 2 more variables: swaggerYamlUrl <chr>, link <chr>
#> # A tibble: 3 × 8
#> api_id version added updated openapiVer swaggerUrl
#> <chr> <chr> <dttm> <dttm> <chr> <chr>
#> 1 apis.gu… 2.2.0 2015-11-26 17:52:26 2023-04-05 13:10:14 3.0.0 https://a…
#> 2 fec.gov 1.0 2018-11-20 00:04:28 2023-03-06 07:12:59 3.0.0 https://a…
#> 3 googlea… v3 2020-11-02 10:32:34 2023-04-21 23:09:23 3.0.0 https://a…
#> # ℹ 2 more variables: swaggerYamlUrl <chr>, link <chr>
DSLC.io/wapir | Jon Harmon | wapir.io