Open csdenboer opened 5 years ago
Hi @csdenboer, This is the way I did it on a project of mine:
urls.py
urlpatterns = [
...,
url(
r'website/(?P<website_pk>[^/.]+)/product/(?P<product_id>[^/.]+)/reco/',
get_similar_products_by_client_reference
),
]
search.py
@swagger_auto_schema(tags=["Recommendation"],
method="GET",
responses={"200": LightProductSerializer(many=True)},
manual_parameters=[
Parameter(name="product_id",
required=True,
type="string",
in_="path",
description="Client reference for the product",)
])
@api_view(["GET"])
@permission_classes((ReadRecommendationPermission,))
def get_similar_products_by_client_reference(request, website_pk, product_id):
...
And this is what you get:
it works like a charm!
Is there any possibility to set the response with multiple serializers lists? For example when my view return the next response:
Response({ 'listA': ASerializer(many=True), 'listB':BSerializer(many=True), 'listC': CSerializer(many=True) })
Is it possible to document a path parameter that is defined in an url, e.g. document 'currency' in
url(r'^v1/object/(?P<currency>\busd\b|\beur\b|\bkrw\b)/$', View.as_view())
? Is yes, how? Thanks!