<?xml version="1.0" ?>

<resources xmlns="https://api-platform.com/schema/metadata"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="https://api-platform.com/schema/metadata https://api-platform.com/schema/metadata/metadata-2.0.xsd"
>
    <resource class="%sylius.model.product_image.class%" shortName="ProductImage">
        <attribute name="validation_groups">sylius</attribute>

        <collectionOperations>
            <collectionOperation name="admin_get">
                <attribute name="method">GET</attribute>
                <attribute name="path">/admin/product-images</attribute>
                <attribute name="filters">
                    <attribute>sylius.api.product_image_product_variants_filter</attribute>
                </attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>admin:product_image:index</attribute>
                        <attribute>sylius:admin:product_image:index</attribute>
                    </attribute>
                </attribute>
                <attribute name="openapi_context">
                    <attribute name="parameters">
                        <attribute>
                            <attribute name="name">imageFilter</attribute>
                            <attribute name="in">query</attribute>
                            <attribute name="description">Provide one of supported image liip imagine filters</attribute>
                            <attribute name="schema">
                                <attribute name="type">string</attribute>
                            </attribute>
                        </attribute>
                    </attribute>
                </attribute>
            </collectionOperation>

            <collectionOperation name="admin_post">
                <attribute name="method">POST</attribute>
                <attribute name="path">/admin/products/{code}/images</attribute>
                <attribute name="controller">Sylius\Bundle\ApiBundle\Controller\UploadProductImageAction</attribute>
                <attribute name="deserialize">false</attribute>
                <attribute name="openapi_context">
                    <attribute name="parameters">
                        <attribute>
                            <attribute name="name">code</attribute>
                            <attribute name="in">path</attribute>
                            <attribute name="required">true</attribute>
                            <attribute name="schema">
                                <attribute name="type">string</attribute>
                            </attribute>
                        </attribute>
                    </attribute>
                    <attribute name="requestBody">
                        <attribute name="content">
                            <attribute name="multipart/form-data">
                                <attribute name="schema">
                                    <attribute name="type">object</attribute>
                                    <attribute name="properties">
                                        <attribute name="file">
                                            <attribute name="type">string</attribute>
                                            <attribute name="format">binary</attribute>
                                        </attribute>
                                        <attribute name="type">
                                            <attribute name="type">string</attribute>
                                        </attribute>
                                        <attribute name="productVariants[]">
                                            <attribute name="type">array</attribute>
                                            <attribute name="items">
                                                <attribute name="type">string</attribute>
                                                <attribute name="format">iri-reference</attribute>
                                            </attribute>
                                        </attribute>
                                    </attribute>
                                </attribute>
                                <attribute name="encoding">
                                    <attribute name="productVariants[]">
                                        <attribute name="style">form</attribute>
                                        <attribute name="explode">true</attribute>
                                    </attribute>
                                </attribute>
                            </attribute>
                        </attribute>
                    </attribute>
                </attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>admin:product_image:show</attribute>
                        <attribute>sylius:admin:product_image:show</attribute>
                    </attribute>
                </attribute>
            </collectionOperation>
        </collectionOperations>

        <itemOperations>
            <itemOperation name="admin_get">
                <attribute name="method">GET</attribute>
                <attribute name="path">/admin/product-images/{id}</attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>admin:product_image:show</attribute>
                        <attribute>sylius:admin:product_image:show</attribute>
                    </attribute>
                </attribute>
                <attribute name="openapi_context">
                    <attribute name="parameters">
                        <attribute>
                            <attribute name="name">imageFilter</attribute>
                            <attribute name="in">query</attribute>
                            <attribute name="description">Provide one of supported image liip imagine filters</attribute>
                            <attribute name="schema">
                                <attribute name="type">string</attribute>
                            </attribute>
                        </attribute>
                    </attribute>
                </attribute>
            </itemOperation>

            <itemOperation name="shop_get">
                <attribute name="method">GET</attribute>
                <attribute name="path">/shop/product-images/{id}</attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>shop:product_image:show</attribute>
                        <attribute>sylius:shop:product_image:show</attribute>
                    </attribute>
                </attribute>
                <attribute name="openapi_context">
                    <attribute name="parameters">
                        <attribute>
                            <attribute name="name">imageFilter</attribute>
                            <attribute name="in">query</attribute>
                            <attribute name="description">Provide one of supported image liip imagine filters</attribute>
                            <attribute name="schema">
                                <attribute name="type">string</attribute>
                            </attribute>
                        </attribute>
                    </attribute>
                </attribute>
            </itemOperation>

            <itemOperation name="admin_put">
                <attribute name="method">PUT</attribute>
                <attribute name="path">/admin/product-images/{id}</attribute>
                <attribute name="denormalization_context">
                    <attribute name="groups">
                        <attribute>admin:product_image:update</attribute>
                        <attribute>sylius:admin:product_image:update</attribute>
                    </attribute>
                </attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>admin:product_image:show</attribute>
                        <attribute>sylius:admin:product_image:show</attribute>
                    </attribute>
                </attribute>
            </itemOperation>

            <itemOperation name="admin_delete">
                <attribute name="method">DELETE</attribute>
                <attribute name="path">/admin/product-images/{id}</attribute>
            </itemOperation>
        </itemOperations>

        <subresourceOperations>
            <subresourceOperation name="api_products_images_get_subresource">
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>admin:product_image:show</attribute>
                        <attribute>sylius:admin:product_image:show</attribute>
                    </attribute>
                </attribute>
            </subresourceOperation>
        </subresourceOperations>

        <property name="id" identifier="true" writable="false" />
        <property name="path" required="true" />
        <property name="type" />
        <property name="variants" />
    </resource>
</resources>
