Skip to content

Commit

Permalink
Merge branch 'v0.2.0' into 'main'
Browse files Browse the repository at this point in the history
change: schema-name to schema-title according to json specifiction

See merge request fluxlabs/flux-eco/json-schema-document!4
  • Loading branch information
mstuder committed Apr 3, 2022
2 parents 50c2956 + d2cc957 commit 0e6d197
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 13 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CHANGELOG

## [0.2.0]
Changed name to title - according to the json schema specification

## [0.1.0]
A schema document MUST have a name property

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "flux-eco/json-schema-document",
"description": "Component for flux-capacitor apps developed by fluxlabs",
"version": "0.1.0",
"version": "0.2.0",
"type": "flux-app",
"keywords": [
"flux-eco",
Expand Down
4 changes: 2 additions & 2 deletions src/Adapters/Api/SchemaDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public function getProperties() : array
}

/** @return string */
public function getName() : string
public function getTitle() : string
{
return $this->schemaDocument->getName();
return $this->schemaDocument->getTitle();
}
}
3 changes: 1 addition & 2 deletions src/Adapters/SchemaFileReader/SchemaFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ public static function new(

public static function fromFilePath(string $filePath): self
{
$pathInfo = pathinfo($filePath);
$schemaObjectName = $pathInfo['filename'];
$schemaObjectName = pathinfo($filePath, PATHINFO_FILENAME);
$schemaObjectArray = yaml_parse(file_get_contents($filePath));
return new self($filePath, $schemaObjectName, $schemaObjectArray);
}
Expand Down
14 changes: 7 additions & 7 deletions src/Core/Domain/SchemaDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@

class SchemaDocument
{
private string $name;
private string $title;
/** @var Models\SchemaObject[] */
private array $properties;

private function __construct(string $name, array $schemaObjects)
private function __construct(string $title, array $schemaObjects)
{
$this->name = $name;
$this->title = $title;
$this->properties = $schemaObjects;
}

public static function new(
string $name,
string $title,
array $schemaObjects
) : self {
return new self($name, $schemaObjects);
return new self($title, $schemaObjects);
}

public function getName() : string
public function getTitle() : string
{
return $this->name;
return $this->title;
}

/** @return Models\SchemaObject[] */
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Ports/SchemaFileService.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ public function getSchemaDocument(string $jsonSchemaYamlFilePath) : Domain\Schem
$properties[$key] = Domain\Models\SchemaObject::new($key, $property['type']);
}

return Domain\SchemaDocument::new($schema['name'], $properties);
return Domain\SchemaDocument::new($schema['title'], $properties);
}
}

0 comments on commit 0e6d197

Please sign in to comment.