Skip to content

[WIP] ReferenceType Configuration #351

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

Conversation

Drachenkaetzchen
Copy link

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #350
License MIT
Doc PR none yet

This is a WIP PR for fixing #350.

Right now, IRIs are relative, which means that it's impossible to tell from which host they come from. This PR attempts to fix that.

Tasks:

  • Reference Type can set in the configuration via the new configuration key reference_type. The supported values are absolute_url, absolute_path, relative_path and network_path, as supported by the UrlGeneratorInterface
  • The configuration key's default value is absolute_path to ensure BC
  • CollectionNormalizer uses the request_uri as @id. This must be changed, but I'm not certain what's reasonable
  • Documentation PR
  • Unit Tests / Behat Tests. I'm not sure on how to test absolute_url and network_path as host names change of course, and I don't know how to do a Behat Test with a changing configuration

@theofidry
Copy link
Contributor

@FELICITUS don't worry if the StyleCI fails, it cannot pass completely atm.

I'm not sure if this should be configuration, To me it would make more sense to have the FQCN for the reference type. But @dunglas is more qualified than me to answer this Hydra question.

@dunglas
Copy link
Member

dunglas commented Nov 29, 2015

AFAIK relatives IRIs are perfect valid according to JSON-LD and Hydra spec. All available tools implementing these specs are able to deal with relative URLs. Using relative URLs has the advantage of reducing the size of the JSON document (performance, bandwidth...).
However, I've nothing against making this behavior configurable if we keep relative URLs as default.

@Drachenkaetzchen
Copy link
Author

@dunglas yes, relative URIs should be default. However, in my scenario, I need to know the source of an entity, a relative URI was not enough in my case ;)

@dunglas dunglas mentioned this pull request Nov 29, 2015
@dunglas
Copy link
Member

dunglas commented Nov 30, 2015

Yes it would be nice to have the option and I'll be pleased to merge your marge when finished.

A workaround that works too is to change the JSON-LD document until retrieved and before saving it to transform relative URLs to absolute ones.

@sroze
Copy link
Contributor

sroze commented Dec 18, 2015

@FELICITUS any news about this PR?

@Drachenkaetzchen
Copy link
Author

@sroze unfortunately no, I haven't had time to improve it yet.

@dunglas
Copy link
Member

dunglas commented Aug 19, 2016

@FELICITUS any update regarding this PR? It would be nice to have.

@Drachenkaetzchen
Copy link
Author

Unfortunately no, tbh I completely forgot about this. I will put it on my list :)

@Simperfit
Copy link
Contributor

@FELICITUS Do you want some help on this ?

@Drachenkaetzchen
Copy link
Author

@Simperfit sure, any help is appreciated :)

@Simperfit
Copy link
Contributor

@FELICITUS Maybe you should restart from the actual master and ill be glad to help you ;)

@Drachenkaetzchen
Copy link
Author

@Simperfit if you have an idea regarding Unit Tests / Behat Tests. I'm not sure on how to test absolute_url and network_path as host names change of course, and I don't know how to do a Behat Test with a changing configuration please let me know, that's the issue I'm having most trouble with

@Simperfit
Copy link
Contributor

I was searching in this way too @FELICITUS but couldn't find anything about it. @sroze Do you have any idea how we can test that in behat ?

@maechler
Copy link
Contributor

I just came across this issue. It looks quite similar to the pull request I just opened: #751

I am not yet sure what would be the best way to add this feature..
Which way to go?

@Simperfit
Copy link
Contributor

Simperfit commented Oct 2, 2016

@maechler I think this is the right way to go

leesiongchan pushed a commit to leesiongchan/api-platform-core that referenced this pull request Mar 6, 2018
@Simperfit
Copy link
Contributor

Simperfit commented Apr 6, 2018

I think this should be restarted from existing master, if you want to, feel free to ping me, i'll help ;).

@Simperfit Simperfit closed this Apr 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants