-
-
Notifications
You must be signed in to change notification settings - Fork 73
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
It should be possible to list the content type of items in a container/collection #76
Comments
I recently did this in our own project integration of I would propose to include @pigeonflight for now, this can be done by registering your own from my.project import IMyProjectLayer
from plone.restapi.interfaces import ISerializeToJsonSummary
from plone.restapi.serializer.summary import DefaultJSONSummarySerializer
from zope.component import adapter
from zope.interface import implementer
from zope.interface import Interface
@implementer(ISerializeToJsonSummary)
@adapter(Interface, IMyProjectLayer)
class MyJSONSummarySerializer(DefaultJSONSummarySerializer):
"""Customize summary representations to include the object's portal_type.
"""
def __init__(self, context, request):
self.context = context
self.request = request
def __call__(self):
# Get the default summary first, then modify it as needed
summary = super(MyJSONSummarySerializer, self).__call__()
# Include portal_type
summary['@type'] = self.context.portal_type
return summary <adapter factory=".summary.MyJSONSummarySerializer" /> Note that this will override the Also note that |
@lukasgraf thanks for the pointer, will look into that. Definitely keep description. plone.restapi advertises itself as an "out of the box" restful api for Plone. In that context the description is important. Having the type will allow me to filter the json results based on content type. BTW.. I'm on a project now where we're using Plone as an API. update: |
@lukasgraf +1 for adding a type to listing (and keep the description). I wasn't 100% sure if we should use "@type" or just "type" since "@type" has a very specifig meaning in JSON-LD/Hydra. Though, I think "@type" is the correct key to use. See: https://www.w3.org/TR/json-ld/#typed-values |
I also believe The way I understand it, we would eventually be building our own dynamic JSON-LD contexts, vocabularies and types, based on information from FTIs, (probably annotated) schema interfaces, and field types. Related: #11 |
Current behaviour
If I do an http get on a collection (which I have called "hey") with two items. It returns information about the two items in the "member" array. However for each member I only get somethign like this:
Suggested (Improved behaviour)
I would want the content type added as @type to the metadata.
Full JSON output (for reference)
For completeness I've included the full JSON output below
The text was updated successfully, but these errors were encountered: