Skip to content

Commit e9cb74d

Browse files
authored
Doc for Schema Generator 3.0 (#1251)
1 parent e2831ca commit e9cb74d

File tree

3 files changed

+97
-427
lines changed

3 files changed

+97
-427
lines changed

schema-generator/configuration.md

Lines changed: 67 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ Example:
114114
abstract: true
115115
```
116116

117-
118117
## Forcing a Nullable Property
119118

120119
Force a property to be (or to not be) `nullable`.
@@ -135,13 +134,12 @@ The `@Assert\NotNull` constrain is automatically added.
135134
<?php
136135
137136
/**
138-
* @var string The name of the item.
137+
* The name of the item.
139138
*
140139
* @ORM\Column
141-
* @Assert\Type(type="string")
142140
* @Assert\NotNull
143141
*/
144-
private $name;
142+
private string $name;
145143
```
146144

147145
## Forcing a Unique Property
@@ -178,12 +176,12 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
178176
class Person
179177
{
180178
/**
181-
* @var string Email address.
179+
* Email address.
182180
*
183181
* @ORM\Column
184182
* @Assert\Email
185183
*/
186-
private $email;
184+
private string $email;
187185
```
188186

189187
## Making a Property Read-Only
@@ -251,14 +249,16 @@ use Symfony\Component\Serializer\Annotation\Groups;
251249
class Person
252250
{
253251
/**
254-
* @var string The name of the item.
252+
* The name of the item.
253+
*
254+
* @see https://schema.org/name
255255
*
256256
* @ORM\Column(nullable=true)
257257
* @Assert\Type(type="string")
258258
* @Iri("https://schema.org/name")
259259
* @Groups({"public"})
260260
*/
261-
private $name;
261+
private string $name;
262262
263263
```
264264

@@ -304,12 +304,14 @@ use Doctrine\ORM\Mapping as ORM;
304304
class Product
305305
{
306306
/**
307-
* @var QuantitativeValue|null the weight of the product or person
307+
* the weight of the product or person
308+
*
309+
* @see http://schema.org/weight
308310
*
309311
* @ORM\Embedded(class="App\Entity\QuantitativeValue", columnPrefix="weight_")
310312
* @ApiProperty(iri="http://schema.org/weight")
311313
*/
312-
private $weight;
314+
private ?QuantitativeValue $weight = null;
313315
314316
```
315317

@@ -479,7 +481,7 @@ You can also use any other vocabulary. Check the [Linked Open Vocabularies](http
479481

480482
For instance, to generate a data model from the [Video Game Ontology](http://purl.org/net/VideoGameOntology), use the following config file:
481483

482-
```
484+
```yaml
483485
rdfa:
484486
- http://vocab.linkeddata.es/vgo/GameOntologyv3.owl # The URL of the vocabulary definition
485487
@@ -508,33 +510,35 @@ header: |
508510
/*
509511
* This file is part of the Ecommerce package.
510512
*
511-
* (c) Kévin Dunglas <[email protected]>
513+
* (c) Kévin Dunglas <[email protected]>
512514
*
513515
* For the full copyright and license information, please view the LICENSE
514516
* file that was distributed with this source code.
515517
*/
516518
```
517519

518-
519520
## Full Configuration Reference
520521

521522
```yaml
522523
config:
523524
524-
# RDFa files
525-
rdfa:
525+
# RDF vocabularies
526+
vocabularies:
526527
527528
# Prototype
528529
-
529530
530-
# RDFa URI to use
531-
uri: 'https://schema.org/docs/schema_org_rdfa.html' # Example: https://schema.org/docs/schema_org_rdfa.html
531+
# RDF vocabulary to use
532+
uri: 'https://schema.org/version/latest/schemaorg-current-http.rdf' # Example: 'https://schema.org/version/latest/schemaorg-current-http.rdf'
532533
533-
# RDFa URI data format
534+
# RDF vocabulary format
534535
format: null # Example: rdfxml
535536
536-
# OWL relation files to use
537-
relations:
537+
# Namespace of the vocabulary to import
538+
vocabularyNamespace: 'http://schema.org/' # Example: 'http://www.w3.org/ns/activitystreams#'
539+
540+
# OWL relation files containing cardinality information in the GoodRelations format
541+
relations: # Example: 'https://purl.org/goodrelations/v1.owl'
538542
539543
# Default:
540544
- https://purl.org/goodrelations/v1.owl
@@ -554,26 +558,32 @@ config:
554558
# Is the ID writable? Only applicable if "generationStrategy" is "uuid".
555559
writable: false
556560
561+
# Set to "child" to generate the id on the child class, and "parent" to use the parent class instead.
562+
onClass: child # One of "child"; "parent"
563+
557564
# Generate interfaces and use Doctrine's Resolve Target Entity feature
558565
useInterface: false
559566
560567
# Emit a warning if a property is not derived from GoodRelations
561568
checkIsGoodRelations: false
562569
563570
# A license or any text to use as header of generated files
564-
header: false # Example: // (c) Kévin Dunglas <[email protected]>
571+
header: false # Example: '// (c) Kévin Dunglas <[email protected]>'
565572
566573
# PHP namespaces
567574
namespaces:
568575
576+
# The global namespace's prefix
577+
prefix: null # Example: App\
578+
569579
# The namespace of the generated entities
570-
entity: App\Entity # Example: Acme\Entity
580+
entity: App\Entity # Example: App\Entity
571581
572582
# The namespace of the generated enumerations
573-
enum: App\Enum # Example: Acme\Enum
583+
enum: App\Enum # Example: App\Enum
574584
575585
# The namespace of the generated interfaces
576-
interface: App\Model # Example: Acme\Model
586+
interface: App\Model # Example: App\Model
577587
578588
# Doctrine
579589
doctrine:
@@ -584,14 +594,17 @@ config:
584594
# The Resolve Target Entity Listener config file pass
585595
resolveTargetEntityConfigPath: null
586596
597+
# Doctrine inheritance annotations (if set, no other annotations are generated)
598+
inheritanceAnnotations: []
599+
587600
# Symfony Validator Component
588601
validator:
589602
590603
# Generate @Assert\Type annotation
591604
assertType: false
592605
593606
# The value of the phpDoc's @author annotation
594-
author: false # Example: Kévin Dunglas <[email protected]>
607+
author: false # Example: 'Kévin Dunglas <[email protected]>'
595608
596609
# Visibility of entities fields
597610
fieldVisibility: private # One of "private"; "protected"; "public"
@@ -601,15 +614,25 @@ config:
601614
602615
# Set this flag to true to generate fluent setter, adder and remover methods
603616
fluentMutatorMethods: false
617+
rangeMapping:
618+
619+
# Prototype
620+
name: ~
604621
605-
# Schema.org's types to use
622+
# Generate all types, even if an explicit configuration exists
623+
allTypes: false
624+
625+
# Types to import from the vocabulary
606626
types:
607627
608628
# Prototype
609629
id:
610630
611-
# Namespace of the vocabulary the type belongs to.
612-
vocabularyNamespace: 'http://schema.org/'
631+
# Exclude this type, even if "allTypes" is set to true"
632+
exclude: false
633+
634+
# Namespace of the vocabulary of this type (defaults to the global "vocabularyNamespace" entry)
635+
vocabularyNamespace: null # Example: 'http://www.w3.org/ns/activitystreams#'
613636
614637
# Is the class abstract? (null to guess)
615638
abstract: null
@@ -627,8 +650,8 @@ config:
627650
interface: null
628651
doctrine:
629652
630-
# The Doctrine inheritance mapping type (override the guessed one)
631-
inheritanceMapping: null
653+
# Doctrine annotations (if set, no other annotations are generated)
654+
annotations: []
632655
633656
# The parent class, set to false for a top level class
634657
parent: false
@@ -645,6 +668,9 @@ config:
645668
# Prototype
646669
id:
647670
671+
# Exclude this property, even if "allProperties" is set to true"
672+
exclude: false
673+
648674
# The property range
649675
range: null # Example: Offer
650676
@@ -653,11 +679,17 @@ config:
653679
cardinality: unknown # One of "(0..1)"; "(0..*)"; "(1..1)"; "(1..*)"; "(*..0)"; "(*..1)"; "(*..*)"; "unknown"
654680
655681
# The doctrine column annotation content
656-
ormColumn: null # Example: type="decimal", precision=5, scale=1, options={"comment" = "my comment"}
682+
ormColumn: null # Example: 'type="decimal", precision=5, scale=1, options={"comment" = "my comment"}'
657683
658684
# Symfony Serialization Groups
659685
groups: []
660686
687+
# The doctrine mapped by attribute
688+
mappedBy: null # Example: partOfSeason
689+
690+
# The doctrine inversed by attribute
691+
inversedBy: null # Example: episodes
692+
661693
# Is the property readable?
662694
readable: true
663695
@@ -674,7 +706,7 @@ config:
674706
embedded: false
675707
676708
# The property columnPrefix
677-
columnPrefix: false # Example: "weight_"
709+
columnPrefix: false
678710
679711
# Annotation generators to use
680712
annotationGenerators:
@@ -685,4 +717,7 @@ config:
685717
- ApiPlatform\SchemaGenerator\AnnotationGenerator\ApiPlatformCoreAnnotationGenerator
686718
- ApiPlatform\SchemaGenerator\AnnotationGenerator\ConstraintAnnotationGenerator
687719
- ApiPlatform\SchemaGenerator\AnnotationGenerator\SerializerGroupsAnnotationGenerator
720+
721+
# Directories for custom generator twig templates
722+
generatorTemplates: []
688723
```

0 commit comments

Comments
 (0)