Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalizers do not include extended object properties #14

Open
zexa opened this issue Sep 26, 2019 · 0 comments
Open

Normalizers do not include extended object properties #14

zexa opened this issue Sep 26, 2019 · 0 comments

Comments

@zexa
Copy link

zexa commented Sep 26, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant