diff --git a/src/open_producten/producttypes/router.py b/src/open_producten/producttypes/router.py index 823a98a..b76d295 100644 --- a/src/open_producten/producttypes/router.py +++ b/src/open_producten/producttypes/router.py @@ -13,29 +13,29 @@ ProductTypesRouter = DefaultRouter() ProductTypesRouter.register("producttypes", ProductTypeViewSet, basename="producttype") ProductTypesRouter.register( - "producttypes/(?P[^/.]+)/links", + "producttypes/(?P[^/.]+)/links", ProductTypeLinkViewSet, basename="producttype-link", ) ProductTypesRouter.register( - "producttypes/(?P[^/.]+)/prices", + "producttypes/(?P[^/.]+)/prices", ProductTypePriceViewSet, basename="producttype-price", ) ProductTypesRouter.register( - "producttypes/(?P[^/.]+)/questions", + "producttypes/(?P[^/.]+)/questions", ProductTypeQuestionViewSet, basename="producttype-question", ) ProductTypesRouter.register( - "producttypes/(?P[^/.]+)/fields", + "producttypes/(?P[^/.]+)/fields", ProductTypeFieldViewSet, basename="producttype-field", ) ProductTypesRouter.register("categories", CategoryViewSet, basename="category") ProductTypesRouter.register( - "categories/(?P[^/.]+)/questions", + "categories/(?P[^/.]+)/questions", CategoryQuestionViewSet, basename="category-question", ) diff --git a/src/open_producten/producttypes/views.py b/src/open_producten/producttypes/views.py index 4cbb25e..05f9d81 100644 --- a/src/open_producten/producttypes/views.py +++ b/src/open_producten/producttypes/views.py @@ -1,5 +1,4 @@ from django.shortcuts import get_object_or_404 - from rest_framework.viewsets import ModelViewSet from open_producten.producttypes.models import ( @@ -33,11 +32,11 @@ class ProductTypeViewSet(BaseModelViewSet): class ProductTypeChildViewSet(BaseModelViewSet): def get_queryset(self): - return self.queryset.filter(product_type_id=self.kwargs["id"]) + return self.queryset.filter(product_type_id=self.kwargs["product_type_id"]) def perform_create(self, serializer): serializer.save( - product_type=get_object_or_404(ProductType, id=self.kwargs["id"]) + product_type=get_object_or_404(ProductType, id=self.kwargs["product_type_id"]) ) @@ -70,10 +69,10 @@ class CategoryViewSet(BaseModelViewSet): class CategoryChildViewSet(BaseModelViewSet): def get_queryset(self): - return self.queryset.filter(category_id=self.kwargs["id"]) + return self.queryset.filter(category_id=self.kwargs["category_id"]) def perform_create(self, serializer): - serializer.save(category=get_object_or_404(Category, id=self.kwargs["id"])) + serializer.save(category=get_object_or_404(Category, id=self.kwargs["category_id"])) class CategoryQuestionViewSet(CategoryChildViewSet): diff --git a/src/openapi.yaml b/src/openapi.yaml index 95557ff..8d4ffe5 100644 --- a/src/openapi.yaml +++ b/src/openapi.yaml @@ -45,16 +45,15 @@ paths: schema: $ref: '#/components/schemas/Category' description: '' - /api/v1/categories/{id}/: + /api/v1/categories/{category_id}/questions/: get: - operationId: categories_retrieve + operationId: categories_questions_list parameters: - in: path - name: id + name: category_id schema: type: string format: uuid - description: A UUID string identifying this Category. required: true tags: - categories @@ -67,17 +66,18 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Category' + type: array + items: + $ref: '#/components/schemas/Question' description: '' - put: - operationId: categories_update + post: + operationId: categories_questions_create parameters: - in: path - name: id + name: category_id schema: type: string format: uuid - description: A UUID string identifying this Category. required: true tags: - categories @@ -85,42 +85,29 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Category' + $ref: '#/components/schemas/Question' required: true security: - cookieAuth: [ ] - basicAuth: [ ] - { } responses: - '200': + '201': content: application/json: schema: - $ref: '#/components/schemas/Category' + $ref: '#/components/schemas/Question' description: '' - delete: - operationId: categories_destroy + /api/v1/categories/{category_id}/questions/{id}/: + get: + operationId: categories_questions_retrieve parameters: - in: path - name: id + name: category_id schema: type: string format: uuid - description: A UUID string identifying this Category. required: true - tags: - - categories - security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } - responses: - '204': - description: No response body - /api/v1/categories/{id}/questions/: - get: - operationId: categories_questions_list - parameters: - in: path name: id schema: @@ -139,13 +126,17 @@ paths: content: application/json: schema: - type: array - items: - $ref: '#/components/schemas/Question' + $ref: '#/components/schemas/Question' description: '' - post: - operationId: categories_questions_create + put: + operationId: categories_questions_update parameters: + - in: path + name: category_id + schema: + type: string + format: uuid + required: true - in: path name: id schema: @@ -166,16 +157,21 @@ paths: - basicAuth: [ ] - { } responses: - '201': + '200': content: application/json: schema: $ref: '#/components/schemas/Question' description: '' - /api/v1/categories/{id}/questions/{id}/: - get: - operationId: categories_questions_retrieve + delete: + operationId: categories_questions_destroy parameters: + - in: path + name: category_id + schema: + type: string + format: uuid + required: true - in: path name: id schema: @@ -189,22 +185,42 @@ paths: - cookieAuth: [ ] - basicAuth: [ ] - { } + responses: + '204': + description: No response body + /api/v1/categories/{id}/: + get: + operationId: categories_retrieve + parameters: + - in: path + name: id + schema: + type: string + format: uuid + description: A UUID string identifying this Category. + required: true + tags: + - categories + security: + - cookieAuth: [ ] + - basicAuth: [ ] + - { } responses: '200': content: application/json: schema: - $ref: '#/components/schemas/Question' + $ref: '#/components/schemas/Category' description: '' put: - operationId: categories_questions_update + operationId: categories_update parameters: - in: path name: id schema: type: string format: uuid - description: A UUID string identifying this Question. + description: A UUID string identifying this Category. required: true tags: - categories @@ -212,7 +228,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Question' + $ref: '#/components/schemas/Category' required: true security: - cookieAuth: [ ] @@ -223,17 +239,17 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Question' + $ref: '#/components/schemas/Category' description: '' delete: - operationId: categories_questions_destroy + operationId: categories_destroy parameters: - in: path name: id schema: type: string format: uuid - description: A UUID string identifying this Question. + description: A UUID string identifying this Category. required: true tags: - categories @@ -355,16 +371,16 @@ paths: responses: '204': description: No response body - /api/v1/producttypes/{id}/fields/: + /api/v1/producttypes/{product_type_id}/fields/: get: operationId: producttypes_fields_list parameters: - in: path - name: id + name: product_type_id schema: type: string format: uuid - description: A UUID string identifying this Field. + description: The product type that this field is part of required: true tags: - producttypes @@ -385,11 +401,11 @@ paths: operationId: producttypes_fields_create parameters: - in: path - name: id + name: product_type_id schema: type: string format: uuid - description: A UUID string identifying this Field. + description: The product type that this field is part of required: true tags: - producttypes @@ -410,7 +426,7 @@ paths: schema: $ref: '#/components/schemas/Field' description: '' - /api/v1/producttypes/{id}/fields/{id}/: + /api/v1/producttypes/{product_type_id}/fields/{id}/: get: operationId: producttypes_fields_retrieve parameters: @@ -421,6 +437,13 @@ paths: format: uuid description: A UUID string identifying this Field. required: true + - in: path + name: product_type_id + schema: + type: string + format: uuid + description: The product type that this field is part of + required: true tags: - producttypes security: @@ -444,6 +467,13 @@ paths: format: uuid description: A UUID string identifying this Field. required: true + - in: path + name: product_type_id + schema: + type: string + format: uuid + description: The product type that this field is part of + required: true tags: - producttypes requestBody: @@ -473,6 +503,13 @@ paths: format: uuid description: A UUID string identifying this Field. required: true + - in: path + name: product_type_id + schema: + type: string + format: uuid + description: The product type that this field is part of + required: true tags: - producttypes security: @@ -482,16 +519,16 @@ paths: responses: '204': description: No response body - /api/v1/producttypes/{id}/links/: + /api/v1/producttypes/{product_type_id}/links/: get: operationId: producttypes_links_list parameters: - in: path - name: id + name: product_type_id schema: type: string format: uuid - description: A UUID string identifying this Product type link. + description: Related product type required: true tags: - producttypes @@ -512,11 +549,11 @@ paths: operationId: producttypes_links_create parameters: - in: path - name: id + name: product_type_id schema: type: string format: uuid - description: A UUID string identifying this Product type link. + description: Related product type required: true tags: - producttypes @@ -537,7 +574,7 @@ paths: schema: $ref: '#/components/schemas/Link' description: '' - /api/v1/producttypes/{id}/links/{id}/: + /api/v1/producttypes/{product_type_id}/links/{id}/: get: operationId: producttypes_links_retrieve parameters: @@ -548,6 +585,13 @@ paths: format: uuid description: A UUID string identifying this Product type link. required: true + - in: path + name: product_type_id + schema: + type: string + format: uuid + description: Related product type + required: true tags: - producttypes security: @@ -571,6 +615,13 @@ paths: format: uuid description: A UUID string identifying this Product type link. required: true + - in: path + name: product_type_id + schema: + type: string + format: uuid + description: Related product type + required: true tags: - producttypes requestBody: @@ -600,6 +651,13 @@ paths: format: uuid description: A UUID string identifying this Product type link. required: true + - in: path + name: product_type_id + schema: + type: string + format: uuid + description: Related product type + required: true tags: - producttypes security: @@ -609,16 +667,16 @@ paths: responses: '204': description: No response body - /api/v1/producttypes/{id}/prices/: + /api/v1/producttypes/{product_type_id}/prices/: get: operationId: producttypes_prices_list parameters: - in: path - name: id + name: product_type_id schema: type: string format: uuid - description: A UUID string identifying this Price. + description: The product type that this price belongs to required: true tags: - producttypes @@ -639,11 +697,11 @@ paths: operationId: producttypes_prices_create parameters: - in: path - name: id + name: product_type_id schema: type: string format: uuid - description: A UUID string identifying this Price. + description: The product type that this price belongs to required: true tags: - producttypes @@ -664,7 +722,7 @@ paths: schema: $ref: '#/components/schemas/Price' description: '' - /api/v1/producttypes/{id}/prices/{id}/: + /api/v1/producttypes/{product_type_id}/prices/{id}/: get: operationId: producttypes_prices_retrieve parameters: @@ -675,6 +733,13 @@ paths: format: uuid description: A UUID string identifying this Price. required: true + - in: path + name: product_type_id + schema: + type: string + format: uuid + description: The product type that this price belongs to + required: true tags: - producttypes security: @@ -698,6 +763,13 @@ paths: format: uuid description: A UUID string identifying this Price. required: true + - in: path + name: product_type_id + schema: + type: string + format: uuid + description: The product type that this price belongs to + required: true tags: - producttypes requestBody: @@ -727,6 +799,13 @@ paths: format: uuid description: A UUID string identifying this Price. required: true + - in: path + name: product_type_id + schema: + type: string + format: uuid + description: The product type that this price belongs to + required: true tags: - producttypes security: @@ -736,16 +815,15 @@ paths: responses: '204': description: No response body - /api/v1/producttypes/{id}/questions/: + /api/v1/producttypes/{product_type_id}/questions/: get: operationId: producttypes_questions_list parameters: - in: path - name: id + name: product_type_id schema: type: string format: uuid - description: A UUID string identifying this Question. required: true tags: - producttypes @@ -766,11 +844,10 @@ paths: operationId: producttypes_questions_create parameters: - in: path - name: id + name: product_type_id schema: type: string format: uuid - description: A UUID string identifying this Question. required: true tags: - producttypes @@ -791,7 +868,7 @@ paths: schema: $ref: '#/components/schemas/Question' description: '' - /api/v1/producttypes/{id}/questions/{id}/: + /api/v1/producttypes/{product_type_id}/questions/{id}/: get: operationId: producttypes_questions_retrieve parameters: @@ -802,6 +879,12 @@ paths: format: uuid description: A UUID string identifying this Question. required: true + - in: path + name: product_type_id + schema: + type: string + format: uuid + required: true tags: - producttypes security: @@ -825,6 +908,12 @@ paths: format: uuid description: A UUID string identifying this Question. required: true + - in: path + name: product_type_id + schema: + type: string + format: uuid + required: true tags: - producttypes requestBody: @@ -854,6 +943,12 @@ paths: format: uuid description: A UUID string identifying this Question. required: true + - in: path + name: product_type_id + schema: + type: string + format: uuid + required: true tags: - producttypes security: