ApiPlatform\Core\Swagger\Serializer\DocumentationNormalizer::getDefinitionSchema PHP Method

getDefinitionSchema() private method

Gets a definition Schema Object.
See also: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#schemaObject
private getDefinitionSchema ( string $resourceClass, ResourceMetadata $resourceMetadata, array $serializerContext = null ) : ArrayObject
$resourceClass string
$resourceMetadata ApiPlatform\Core\Metadata\Resource\ResourceMetadata
$serializerContext array
return ArrayObject
    private function getDefinitionSchema(string $resourceClass, ResourceMetadata $resourceMetadata, array $serializerContext = null) : \ArrayObject
    {
        $definitionSchema = new \ArrayObject(['type' => 'object']);
        if (null !== ($description = $resourceMetadata->getDescription())) {
            $definitionSchema['description'] = $description;
        }
        if (null !== ($iri = $resourceMetadata->getIri())) {
            $definitionSchema['externalDocs'] = ['url' => $iri];
        }
        $options = isset($serializerContext['groups']) ? ['serializer_groups' => $serializerContext['groups']] : [];
        foreach ($this->propertyNameCollectionFactory->create($resourceClass, $options) as $propertyName) {
            $propertyMetadata = $this->propertyMetadataFactory->create($resourceClass, $propertyName);
            $normalizedPropertyName = $this->nameConverter ? $this->nameConverter->normalize($propertyName) : $propertyName;
            if ($propertyMetadata->isRequired()) {
                $definitionSchema['required'][] = $normalizedPropertyName;
            }
            $definitionSchema['properties'][$normalizedPropertyName] = $this->getPropertySchema($propertyMetadata);
        }
        return $definitionSchema;
    }