Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/extending-jsonld-context.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Book
// ...

#[ApiProperty(
types: ['https://schema.org/name'],
iris: ['https://schema.org/name'],
jsonldContext: [
'@id' => 'http://yourcustomid.com',
'@type' => 'http://www.w3.org/2001/XMLSchema#string',
Expand Down Expand Up @@ -61,7 +61,7 @@ The generated context will now have your custom attributes set:
```

Note that you do not have to provide the `@id` attribute. If you do not provide an `@id` attribute,
the value from `iri` will be used.
the value from `iris` will be used.

### Extending the Context of a Whole Resource

Expand Down
10 changes: 7 additions & 3 deletions core/external-vocabularies.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@ class Book
{
// ...

#[ApiProperty(types: ['https://schema.org/name'])]
#[ApiProperty(iris: ['https://schema.org/name'])]
public $name;

// ...
}
```

On a property, `iris` sets the IRI used in the JSON-LD context and in the Hydra documentation. The
`types` option of `#[ApiProperty]` is only used as the `externalDocs` URL of the property in the
JSON Schema.

The generated JSON for products and the related context document will now use external IRIs
according to the specified attributes:

Expand Down Expand Up @@ -57,8 +61,8 @@ An extended list of existing open vocabularies is available on
[the Linked Open Vocabularies (LOV) database](https://lov.linkeddata.es/dataset/lov/).

By default, when using [validations](validation.md) API Platform will try to define known
[Schema.org](https://schema.org) types as IRIs for your properties if you did not provide any in
your `#[ApiProperty]` attributes.
[Schema.org](https://schema.org) types for your properties (the `types` option, used in the JSON
Schema) if you did not provide any in your `#[ApiProperty]` attributes.

- Symfony built-in mapping is:

Expand Down
2 changes: 1 addition & 1 deletion core/graphql.md
Original file line number Diff line number Diff line change
Expand Up @@ -3020,7 +3020,7 @@ class MediaObject
#[ORM\Id, ORM\Column, ORM\GeneratedValue]
protected ?int $id = null;

#[ApiProperty(types: ['https://schema.org/contentUrl'])]
#[ApiProperty(iris: ['https://schema.org/contentUrl'])]
#[Groups(['media_object_read'])]
public ?string $contentUrl = null;

Expand Down
6 changes: 3 additions & 3 deletions symfony/file-upload.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class MediaObject
#[ORM\Id, ORM\Column, ORM\GeneratedValue]
private ?int $id = null;

#[ApiProperty(types: ['https://schema.org/contentUrl'], writable: false)]
#[ApiProperty(iris: ['https://schema.org/contentUrl'], writable: false)]
#[Groups(['media_object:read'])]
public ?string $contentUrl = null;

Expand Down Expand Up @@ -337,7 +337,7 @@ class Book

#[ORM\ManyToOne(targetEntity: MediaObject::class)]
#[ORM\JoinColumn(nullable: true)]
#[ApiProperty(types: ['https://schema.org/image'])]
#[ApiProperty(iris: ['https://schema.org/image'])]
public ?MediaObject $image = null;

// ...
Expand Down Expand Up @@ -476,7 +476,7 @@ class Book
{
// ...

#[ApiProperty(types: ['https://schema.org/contentUrl'])]
#[ApiProperty(iris: ['https://schema.org/contentUrl'])]
#[Groups(['book:read'])]
public ?string $contentUrl = null;

Expand Down
Loading