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

Support Any type in the AnyToRdfConverter #3

Open
joachimvh opened this issue Jul 9, 2021 · 2 comments
Open

Support Any type in the AnyToRdfConverter #3

joachimvh opened this issue Jul 9, 2021 · 2 comments

Comments

@joachimvh
Copy link

Currently the AnyToRdfConverter is hardcoded to only support JSON:

super("application/json", outputType);

The super call also supports arrays so you can have multiple entries there. If the types it supports depend on other factors you probably just want to extend RepresentationConverter and have a custom canHandle implementation.

One potential issues when supporting all types is that this converter might be chosen for conversions it actually can't handle. For example, converting from JSON-LD to Turtle in the CSS works by having one converter convert the JSON-LD to quad objects, and then chain a second converter that converts quad objects to Turtle. But if there is also an AnyToRdfConverter in that array, that one would be chose instead since it says it can do the conversion in 1 step.

There are some ways around this. One of them is to just not put this converter in the main array of converters but put it somewhere further in the store stack, after a regex router rule for example. Another way is to have a more advanced canHandle function so it can detect if it can actually do the conversion or not.

@Zelzahn
Copy link
Contributor

Zelzahn commented Jul 9, 2021

Oh did not know that this was hardcoded. I did write a test for csv input, but then I best look at this test what’s been done wrong that makes this test succeed.

@joachimvh
Copy link
Author

If you call the handle function directly you wouldn't notice this. Setting the input type is only relevant for the canHandle call. The value gets checked there and the request gets rejected if it does not match one of the input types.

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