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

Hydra RFC: Setting the hydra:title property #2645

Open
PaulCombal opened this issue Feb 27, 2024 · 0 comments
Open

Hydra RFC: Setting the hydra:title property #2645

PaulCombal opened this issue Feb 27, 2024 · 0 comments

Comments

@PaulCombal
Copy link

Description

Currently, it is very easy to add a description to an entity's field:

    #[ApiProperty(description: 'Name of the product')]
    private ?string $name = null;

And it gets reflected in the /api/docs.jsonld:

      "hydra:supportedProperty": [
        {
          "@type": "hydra:SupportedProperty",
          "hydra:property": {
            "@id": "#Product\/name",
            "@type": "rdf:Property",
            "rdfs:label": "name",
            "domain": "#Product",
            "range": "xmls:string"
          },
          "hydra:title": "name",
          "hydra:required": false,
          "hydra:readable": true,
          "hydra:writeable": true,
          "hydra:description": "Name of the product"
        },

However, I have yet to find a way to set the "hydra:title" of my property. I am planning to use hydra:title as table header in dynamic tables, this is what this kind of usage that property was meant for.

I tried overriding the context to no avail:

        jsonldContext: [
            'hydra:title' => 'Name'
        ])

Being able to override the name and description should be equally easy to my understanding, when reading the Hydra Core Vocabulary spec:

Hydra also allows enriching both ApiDocumentation and hypermedia controls with human-readable descriptions by applying title and description (as shown in the examples above). The former states a name of such a decorated element that could be displayed as a label. The latter provides its description to be presented i.e. as a hint.

Aforementioned title and description SHOULD take precedence over standard rdfs:label and rdfs:comment.

Example

Proposed implementation:

    #[ApiProperty(
        description: 'Name of the product',
        title: 'The name'
    ]
    private ?string $name = null;

Would produce:

      "hydra:supportedProperty": [
        {
          "@type": "hydra:SupportedProperty",
          "hydra:property": {
            "@id": "#Product\/name",
            "@type": "rdf:Property",
            "rdfs:label": "name",
            "domain": "#Product",
            "range": "xmls:string"
          },
          "hydra:title": "The name",
          "hydra:required": false,
          "hydra:readable": true,
          "hydra:writeable": true,
          "hydra:description": "Name of the product"
        },
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

1 participant