Skip to content

Commit 81e87f0

Browse files
authored
Merge pull request #101 from dunglas/embed_data
Embed Schema.org and GoodRelations files directly in the project
2 parents 286e67b + 5809b1c commit 81e87f0

19 files changed

+20
-52
lines changed
File renamed without changes.
File renamed without changes.

src/TypesGeneratorConfiguration.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,15 @@
2828
*/
2929
final class TypesGeneratorConfiguration implements ConfigurationInterface
3030
{
31-
public const SCHEMA_ORG_RDFA_URL = 'https://schema.org/docs/schema_org_rdfa.html';
32-
public const GOOD_RELATIONS_OWL_URL = 'https://purl.org/goodrelations/v1.owl';
31+
/**
32+
* @see https://schema.org/docs/schema_org_rdfa.html
33+
*/
34+
public const SCHEMA_ORG_RDFA_URL = __DIR__.'/../data/schema.rdfa';
35+
36+
/**
37+
* @see https://purl.org/goodrelations/v1.owl
38+
*/
39+
public const GOOD_RELATIONS_OWL_URL = __DIR__.'/../data/v1.owl';
3340
public const SCHEMA_ORG_NAMESPACE = 'http://schema.org/';
3441

3542
/**
@@ -43,9 +50,7 @@ public function getConfigTreeBuilder(): TreeBuilder
4350
->children()
4451
->arrayNode('rdfa')
4552
->info('RDFa files')
46-
->defaultValue([
47-
['uri' => self::SCHEMA_ORG_RDFA_URL, 'format' => null],
48-
])
53+
->defaultValue([['uri' => realpath(self::SCHEMA_ORG_RDFA_URL), 'format' => 'rdfa']])
4954
->beforeNormalization()
5055
->ifArray()
5156
->then(function (array $v) {
@@ -59,14 +64,15 @@ function ($rdfa) {
5964
->end()
6065
->prototype('array')
6166
->children()
62-
->scalarNode('uri')->defaultValue(self::SCHEMA_ORG_RDFA_URL)->info('RDFa URI to use')->example(self::SCHEMA_ORG_RDFA_URL)->end()
67+
->scalarNode('uri')->defaultValue(realpath(self::SCHEMA_ORG_RDFA_URL))->info('RDFa URI to use')->example('https://schema.org/docs/schema_org_rdfa.html')->end()
6368
->scalarNode('format')->defaultNull()->info('RDFa URI data format')->example('rdfxml')->end()
6469
->end()
6570
->end()
6671
->end()
6772
->arrayNode('relations')
6873
->info('OWL relation files to use')
69-
->defaultValue([self::GOOD_RELATIONS_OWL_URL])
74+
->example('https://purl.org/goodrelations/v1.owl')
75+
->defaultValue([realpath(self::GOOD_RELATIONS_OWL_URL)])
7076
->prototype('scalar')->end()
7177
->end()
7278
->booleanNode('debug')->defaultFalse()->info('Debug mode')->end()

tests/Command/DumpConfigurationTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function testDumpConfiguration()
2626
{
2727
$commandTester = new CommandTester(new DumpConfigurationCommand());
2828
$this->assertEquals(0, $commandTester->execute([]));
29-
$this->assertEquals(<<<YAML
29+
$this->assertEquals(sprintf(<<<'YAML'
3030
config:
3131
3232
# RDFa files
@@ -36,16 +36,16 @@ public function testDumpConfiguration()
3636
-
3737
3838
# RDFa URI to use
39-
uri: 'https://schema.org/docs/schema_org_rdfa.html' # Example: https://schema.org/docs/schema_org_rdfa.html
39+
uri: %s # Example: https://schema.org/docs/schema_org_rdfa.html
4040
4141
# RDFa URI data format
4242
format: null # Example: rdfxml
4343
4444
# OWL relation files to use
45-
relations:
45+
relations: # Example: https://purl.org/goodrelations/v1.owl
4646
4747
# Default:
48-
- https://purl.org/goodrelations/v1.owl
48+
- %s
4949
5050
# Debug mode
5151
debug: false
@@ -196,6 +196,6 @@ interface: null
196196

197197

198198
YAML
199-
, $commandTester->getDisplay());
199+
, realpath(__DIR__.'/../../data/schema.rdfa'), realpath(__DIR__.'/../../data/v1.owl')), $commandTester->getDisplay());
200200
}
201201
}

tests/Command/ExtractCardinalitiesCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function testExtractCardinalities()
2626
{
2727
$commandTester = new CommandTester(new ExtractCardinalitiesCommand());
2828
$this->assertEquals(0, $commandTester->execute(
29-
['--schemaorg-file' => __DIR__.'/../data/schema.rdfa', '--goodrelations-file' => __DIR__.'/../data/v1.owl']
29+
['--schemaorg-file' => __DIR__.'/../../data/schema.rdfa', '--goodrelations-file' => __DIR__.'/../../data/v1.owl']
3030
));
3131

3232
$this->assertEquals(<<<'JSON'

tests/config/address-book.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
rdfa: [{ uri: tests/data/schema.rdfa, format: rdfa }]
2-
relations: [tests/data/v1.owl]
3-
41
# The PHP namespace of generated entities
52
namespaces:
63
entity: 'AddressBook\Entity'

tests/config/blog.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
rdfa: [{ uri: tests/data/schema.rdfa, format: rdfa }]
2-
relations: [tests/data/v1.owl]
31
annotationGenerators: # Generators we want to use
42
- ApiPlatform\SchemaGenerator\AnnotationGenerator\PhpDocAnnotationGenerator
53
- ApiPlatform\SchemaGenerator\AnnotationGenerator\DoctrineOrmAnnotationGenerator

tests/config/ecommerce.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
rdfa: [{ uri: tests/data/schema.rdfa, format: rdfa }]
2-
relations: [tests/data/v1.owl]
31
header: |
42
/*
53
* This file is part of the Ecommerce package.

tests/config/fluent-mutators.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
rdfa: [{ uri: tests/data/schema.rdfa, format: rdfa }]
2-
relations: [tests/data/v1.owl]
3-
41
fluentMutatorMethods: true
52
types:
63
Person:

tests/config/generated-id.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
rdfa: [{ uri: tests/data/schema.rdfa, format: rdfa }]
2-
relations: [tests/data/v1.owl]
3-
41
id:
52
generationStrategy: auto
63
types:

0 commit comments

Comments
 (0)