Skip to content
Merged
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
2 changes: 2 additions & 0 deletions src/Factory/V30/FromCebe.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ enum: isset($schema->enum) ?
self::createSchema($schema->additionalProperties) ?? true) :
true,
format: $schema->format ?? null,
title: $schema->title ?? null,
description: $schema->description ?? null,
);
}

Expand Down
6 changes: 6 additions & 0 deletions src/ValueObject/Partial/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ public function __construct(
* https://datatracker.ietf.org/doc/html/draft-wright-json-schema-validation-00#section-7
*/
public string|null $format = null,
/**
* Keywords that provide additional metadata
* https://json-schema.org/draft/2020-12/json-schema-validation#section-9
*/
public string|null $title = null,
public string|null $description = null,
) {
}
}
6 changes: 6 additions & 0 deletions src/ValueObject/Valid/V30/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ final class Schema extends Validated implements Valid\Schema

public readonly string|null $format;

public readonly string|null $title;
public readonly string|null $description;

/** @var Type[] */
private readonly array $typesItCanBe;

Expand Down Expand Up @@ -104,6 +107,9 @@ public function __construct(

$this->format = $schema->format;

$this->title = $schema->title;
$this->description = $schema->description;

$this->typesItCanBe = array_map(
fn($t) => Type::from($t),
$this->typesItCanBe()
Expand Down
4 changes: 4 additions & 0 deletions tests/fixtures/Helper/PartialHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ public static function createSchema(
array|null $oneOf = null,
Schema|null $not = null,
string|null $format = null,
string|null $title = null,
string|null $description = null,
): Schema {
return new Schema(
type: $type,
Expand Down Expand Up @@ -187,6 +189,8 @@ enum: $enum,
items: $items,
properties: $properties,
format: $format,
title: $title,
description: $description,
);
}
}