api-platform / admin

A beautiful and fully-featured administration interface builder for hypermedia APIs
https://api-platform.com/docs/admin/
MIT License
481 stars 130 forks source link

displaying name of relation in place of iri does not work for https://schema.org #465

Closed PawelSuwinski closed 2 years ago

PawelSuwinski commented 2 years ago

Description

When using https://schema.org displaying name in place of iri does not work, so this literal hint does not work (or any defaults generated from schema-generator): https://api-platform.com/docs/admin/schema.org/#displaying-related-resources-name-instead-of-its-iri

only this one would:

#[ApiProperty(iri: "http://schema.org/name")]
private $name;

Name hinting is hardcoded to http://schema.org: https://github.com/api-platform/admin/blob/46b68715f1fd40e5916cd2e8d877808523b3b3b8/src/hydra/schemaAnalyzer.ts#L21

Possible Solution
Match https also, i.e.

  const field = schema.fields.find(
    (schemaField) => schemaField.id.match('https?://schema.org/name')
);
papppeter commented 1 year ago

Hi,

I couldn't get this feature to work. i tried the original solution based on documentation. (iri does not exists in ApiProperty) `

[ApiProperty(types: ["https://schema.org/name"])]

private ?string $name = null;

` i do see types if is run bin/console api:json-schema:generate

image

so how should i configure to see some name instend of IRI?

thanks for your help

PawelSuwinski commented 1 year ago

Try

#[ApiProperty(iris: ['https://schema.org/name'])]
papppeter commented 1 year ago

[ApiProperty(iris: ['https://schema.org/name'])]

Hi, it just works! thank you. i don't know how i did oversee this.

One more question, could you point to one of the documentation, if it is possible to have automaticaly autocomplet field in related field dropdowns on edit pages?

image

thanks for your help!

PawelSuwinski commented 1 year ago

Autocompletion:

Default values:

papppeter commented 1 year ago

Autocompletion:

Default values:

Thank its a realy good direction.

In this case auto generated admin cannot be used any more? It needs custom code all time.

PawelSuwinski commented 1 year ago

In this case auto generated admin cannot be used any more? It needs custom code all time.

Not necessarily, customized and decorated are only some child components or selected props: https://api-platform.com/docs/admin/customizing/