Skip to content

Commit

Permalink
fix(json-schema): adding collectionKeyType JSON Schema
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshz committed Aug 18, 2021
1 parent 4f363fc commit 632ca2a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/JsonSchema/SchemaFactory.php
Expand Up @@ -215,8 +215,10 @@ private function buildPropertySchema(Schema $schema, string $definitionName, str
$valueSchema = [];
if (null !== $type = $propertyMetadata->getType()) {
if ($isCollection = $type->isCollection()) {
$keyType = method_exists(Type::class, 'getCollectionKeyTypes') ? ($type->getCollectionKeyTypes()[0] ?? null) : $type->getCollectionKeyType();
$valueType = method_exists(Type::class, 'getCollectionValueTypes') ? ($type->getCollectionValueTypes()[0] ?? null) : $type->getCollectionValueType();
} else {
$keyType = null;
$valueType = $type;
}

Expand All @@ -228,7 +230,7 @@ private function buildPropertySchema(Schema $schema, string $definitionName, str
$className = $valueType->getClassName();
}

$valueSchema = $this->typeFactory->getType(new Type($builtinType, $type->isNullable(), $className, $isCollection), $format, $propertyMetadata->isReadableLink(), $serializerContext, $schema);
$valueSchema = $this->typeFactory->getType(new Type($builtinType, $type->isNullable(), $className, $isCollection, $keyType, $valueType), $format, $propertyMetadata->isReadableLink(), $serializerContext, $schema);
}

if (\array_key_exists('type', $propertySchema) && \array_key_exists('$ref', $valueSchema)) {
Expand Down

0 comments on commit 632ca2a

Please sign in to comment.