Skip to content

Normalizers do not include extended object properties #14

@zexa

Description

@zexa

example:

# api.raml
# minimized for brevity
types:
  Post: !include types/post.raml
  PublicPost: !include types/public-post.raml
# types/post.raml
#%RAML 1.0 DataType
displayName: Post item
type: object
properties:
  name:
    description: Post item name.
    type: string
    required: true
  content:
    description: Content of the post item.
    type: string
    required: true
# types/public-post.raml
#%RAML 1.0 DataType
displayName: Post item publicly available information
type: Post
properties:
  owner-id:
    description: Unique item id.
    type: string
    required: true
  id:
    description: Unique item id.
    type: string
    required: true

Generated PublicPostNormalizer results in

// minimized for brievity
class PublicPostNormalizer implements NormalizerInterface, DenormalizerInterface
{
    
    /**
     * @param array $data
     *
     * @return PublicPost
     */
    public function mapToEntity($data)
    {
        $entity = new PublicPost();

        if (isset($data['owner-id'])) {
            $entity->setOwnerId($data['owner-id']);
        }
        
        return $entity;
    }

    /**
     * @param PublicPost $entity
     *
     * @return array
     */
    public function mapFromEntity($entity)
    {
        return [
            'id' => $entity->getId(),
            'owner-id' => $entity->getOwnerId(),
            
        ];
    }
}

which lacks the required properties name and content defined in types/post.raml.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions