Coder Social home page Coder Social logo

Comments (5)

tisto avatar tisto commented on June 19, 2024

Right now we use "member" from hydra:

{
  "@context": "http://www.w3.org/ns/hydra/context.jsonld", 
  "@id": "http://localhost:55001/plone", 
  "@type": "Collection", 
  "member": [
    {
      "@id": "http://localhost:55001/plone/robot-test-folder", 
      "description": "", 
      "title": "Test Folder"
    }, 
    {
      "@id": "http://localhost:55001/plone/front-page", 
      "description": "Congratulations! You have successfully installed Plone.", 
      "title": "Welcome to Plone"
    }
  ], 
  "parent": {}, 
  "portal_type": "SiteRoot"
}```

from plone.restapi.

lukasgraf avatar lukasgraf commented on June 19, 2024

@tisto is this decision still current?

I'm seeing some different approaches being used in the various docs, for example in searching.rst it's @items, and there's some collection+json examples as well.

I don't have any strong feelings towards either style, but it's something that probably needs to be agreed upon quite soon. Also, it's not like we can't ever change it again. For now, I'd like to resolve some contradictions in style in the current docs, and then start implementing things using whatever style is documented.

from plone.restapi.

tisto avatar tisto commented on June 19, 2024

This issue is more meant to be a documentation of the current state than a final decision. @lrowe @bloodbare and me discussed this issue during PLOG, we did not reach a final conclusion though.

I tend to keep the hydra "member" and add a "parent" attribute, just because I don't see strong arguments for a certain option. I'm more than open for suggetions or a discussion...

from plone.restapi.

lukasgraf avatar lukasgraf commented on June 19, 2024

The only issue I see with member and parent is the name collisions you already pointed out in your first comment. We simply can't control what people name their fields, or what fields are named in an addon product they might be using. And the choices available to us in case of a collision aren't pretty:

  • Fail hard, and have certain objects not be retrievable via API
  • Overwrite the existing attribute in the output and introduce a rather subtle bug
  • Have the attribute override our member attribute and omit collection members

Maybe we could handle collisions using one of these strategies:

  • Automatically resolve name conflicts using a conflict resolution algorithm that makes the attribute name unique, and rename that attribute
  • Or: Put a mechanism in place that allows integrators / developers to rename particular fields for serialization by providing a name mapping. Then fail hard in case of a conflict, and display a helpful message indicating that the conflict needs to be resolved by providing such a mapping for field x.

Either of these mechanisms would need to be applied on output as well as input though.

from plone.restapi.

ida avatar ida commented on June 19, 2024

+2 for __parent__ and __children__
The terms are my favorite because the words distinct the relation better than 'items' or 'container' e.g. do, and the underscores should be a pretty safe bet, concerning possible collisions.

from plone.restapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.