Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add_resource() includes schema verbosely when only url to schema is required #270

Open
sannegovaert opened this issue Oct 23, 2024 · 2 comments

Comments

@sannegovaert
Copy link
Contributor

sannegovaert commented Oct 23, 2024

add_resource() is used for the development of write_camtrapdp().

The resources are added with add_resource(schema = path), whereas for schema a path is provided, e.g. "https://raw.githubusercontent.com/tdwg/camtrap-dp/1.0.1/observations-table-schema.json".
add_resource() adds the schema verbosely, while we just want to keep the url.

@sannegovaert sannegovaert changed the title "write_package()" writes inline schema when only url to schema is required write_package() writes inline schema when only url to schema is required Oct 23, 2024
@sannegovaert sannegovaert changed the title write_package() writes inline schema when only url to schema is required add_resource() includes schema verbosely when only url to schema is required Oct 23, 2024
@peterdesmet
Copy link
Member

@sannegovaert wanna take a stab at this? I think it can be done by adding:

schema_url <- if (is_url(schema)) schema else NULL

To:

} else if (is.character(schema)) {
# Path to schema can be unsafe, since schema will be verbosely included
schema <- read_descriptor(schema, safe = FALSE)

And then using schema_url %||% schema when assigning in:

schema = schema

schema = schema

And testing for it.

sannegovaert added a commit to inbo/camtrapdp that referenced this issue Oct 24, 2024
@peterdesmet
Copy link
Member

I addition, I think get_schema() should provide an option to get the character rather than the list. E.g.

get_schema(x, "deployments", verbatim = FALSE)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants