From f0292ee812d783f295a60a361f76458107bfd185 Mon Sep 17 00:00:00 2001 From: Floris272 Date: Tue, 17 Sep 2024 15:01:50 +0200 Subject: [PATCH] update api spec --- .../products/tests/api/test_product.py | 30 +- src/openapi.yaml | 352 ++++++++---------- 2 files changed, 163 insertions(+), 219 deletions(-) diff --git a/src/open_producten/products/tests/api/test_product.py b/src/open_producten/products/tests/api/test_product.py index 2164563..cc0dec6 100644 --- a/src/open_producten/products/tests/api/test_product.py +++ b/src/open_producten/products/tests/api/test_product.py @@ -63,7 +63,7 @@ def test_read_product_without_credentials_returns_error(self): response = self.client.get(self.path) self.assertEqual(response.status_code, 401) - def create_product(self): + def _create_product(self): return ProductFactory.create(bsn="111222333") def test_create_product(self): @@ -218,7 +218,7 @@ def test_create_product_with_data_for_field_not_part_of_product_type_returns_err self.assertEqual(Field.objects.count(), 1) def test_update_product(self): - product = self.create_product() + product = self._create_product() data = self.data | {"end_date": datetime.date(2025, 12, 31)} response = self.put(product.id, data) @@ -227,7 +227,7 @@ def test_update_product(self): self.assertEqual(Product.objects.count(), 1) def test_update_product_without_bsn_or_kvk(self): - product = self.create_product() + product = self._create_product() data = self.data.copy() data.pop("bsn") @@ -250,7 +250,7 @@ def test_update_product_data(self): field = FieldFactory.create( product_type=self.product_type, type=FieldTypes.TEXTFIELD, is_required=True ) - product = self.create_product() + product = self._create_product() data_instance = DataFactory.create(product=product, field=field, value="abc") data = self.data | {"data": [{"id": data_instance.id, "value": "123"}]} @@ -267,7 +267,7 @@ def test_update_product_with_duplicate_data_ids_returns_error(self): field = FieldFactory.create( product_type=self.product_type, type=FieldTypes.TEXTFIELD, is_required=True ) - product = self.create_product() + product = self._create_product() data_instance = DataFactory.create(product=product, field=field, value="abc") data = self.data | { @@ -298,9 +298,9 @@ def test_update_product_with_data_not_part_of_product_returns_error( field = FieldFactory.create( product_type=self.product_type, type=FieldTypes.TEXTFIELD, is_required=True ) - product = self.create_product() + product = self._create_product() data_instance = DataFactory.create( - product=self.create_product(), field=field, value="abc" + product=self._create_product(), field=field, value="abc" ) data = self.data | { @@ -329,7 +329,7 @@ def test_update_product_with_no_existing_data_object_returns_error( FieldFactory.create( product_type=self.product_type, type=FieldTypes.TEXTFIELD, is_required=True ) - product = self.create_product() + product = self._create_product() dummy_id = uuid.uuid4() @@ -357,7 +357,7 @@ def test_update_product_with_invalid_data_returns_error(self): field = FieldFactory.create( product_type=self.product_type, type=FieldTypes.NUMBER, is_required=True ) - product = self.create_product() + product = self._create_product() data_instance = DataFactory.create(product=product, field=field, value="123") data = self.data | { @@ -381,7 +381,7 @@ def test_update_product_with_invalid_data_returns_error(self): ) def test_partial_update_product(self): - product = self.create_product() + product = self._create_product() data = {"end_date": datetime.date(2025, 12, 31)} response = self.patch(product.id, data) @@ -393,7 +393,7 @@ def test_partial_update_product_data(self): field = FieldFactory.create( product_type=self.product_type, type=FieldTypes.TEXTFIELD, is_required=True ) - product = self.create_product() + product = self._create_product() data_instance = DataFactory.create(product=product, field=field, value="abc") data = {"data": [{"id": data_instance.id, "value": "123"}]} @@ -407,7 +407,7 @@ def test_partial_update_product_data(self): self.assertEqual(data_instance.value, "123") def test_read_products(self): - product = self.create_product() + product = self._create_product() response = self.get() @@ -415,7 +415,7 @@ def test_read_products(self): self.assertEqual(response.data, [product_to_dict(product)]) def test_read_product(self): - product = self.create_product() + product = self._create_product() response = self.get(product.id) @@ -423,7 +423,7 @@ def test_read_product(self): self.assertEqual(response.data, product_to_dict(product)) def test_read_product_with_data(self): - product = self.create_product() + product = self._create_product() field = FieldFactory.create( product_type=self.product_type, is_required=True, type="textfield" ) @@ -433,7 +433,7 @@ def test_read_product_with_data(self): self.assertEqual(response.data, product_to_dict(product)) def test_delete_product(self): - product = self.create_product() + product = self._create_product() response = self.delete(product.id) self.assertEqual(response.status_code, 204) diff --git a/src/openapi.yaml b/src/openapi.yaml index a7b2d4f..2cf10ec 100644 --- a/src/openapi.yaml +++ b/src/openapi.yaml @@ -12,9 +12,7 @@ paths: tags: - categories security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -35,9 +33,7 @@ paths: $ref: '#/components/schemas/Category' required: true security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '201': content: @@ -58,9 +54,7 @@ paths: tags: - categories security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -88,9 +82,7 @@ paths: $ref: '#/components/schemas/Question' required: true security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '201': content: @@ -118,9 +110,7 @@ paths: tags: - categories security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -153,9 +143,7 @@ paths: $ref: '#/components/schemas/Question' required: true security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -187,9 +175,7 @@ paths: schema: $ref: '#/components/schemas/PatchedQuestion' security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -216,9 +202,7 @@ paths: tags: - categories security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '204': description: No response body @@ -236,9 +220,7 @@ paths: tags: - categories security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -265,9 +247,7 @@ paths: $ref: '#/components/schemas/Category' required: true security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -293,9 +273,7 @@ paths: schema: $ref: '#/components/schemas/PatchedCategory' security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -316,9 +294,7 @@ paths: tags: - categories security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '204': description: No response body @@ -328,9 +304,7 @@ paths: tags: - conditions security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -351,9 +325,7 @@ paths: $ref: '#/components/schemas/Condition' required: true security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '201': content: @@ -375,9 +347,7 @@ paths: tags: - conditions security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -404,9 +374,7 @@ paths: $ref: '#/components/schemas/Condition' required: true security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -432,9 +400,7 @@ paths: schema: $ref: '#/components/schemas/PatchedCondition' security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -455,9 +421,7 @@ paths: tags: - conditions security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '204': description: No response body @@ -467,9 +431,7 @@ paths: tags: - products security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -490,9 +452,7 @@ paths: $ref: '#/components/schemas/Product' required: true security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '201': content: @@ -514,9 +474,7 @@ paths: tags: - products security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -543,9 +501,7 @@ paths: $ref: '#/components/schemas/ProductUpdate' required: true security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -571,9 +527,7 @@ paths: schema: $ref: '#/components/schemas/PatchedProductUpdate' security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -594,9 +548,7 @@ paths: tags: - products security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '204': description: No response body @@ -606,9 +558,7 @@ paths: tags: - producttypes security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -629,9 +579,7 @@ paths: $ref: '#/components/schemas/ProductType' required: true security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '201': content: @@ -653,9 +601,7 @@ paths: tags: - producttypes security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -682,9 +628,7 @@ paths: $ref: '#/components/schemas/ProductType' required: true security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -710,9 +654,7 @@ paths: schema: $ref: '#/components/schemas/PatchedProductType' security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -733,9 +675,7 @@ paths: tags: - producttypes security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '204': description: No response body @@ -753,9 +693,7 @@ paths: tags: - producttypes security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -784,9 +722,7 @@ paths: $ref: '#/components/schemas/Field' required: true security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '201': content: @@ -815,9 +751,7 @@ paths: tags: - producttypes security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -851,9 +785,7 @@ paths: $ref: '#/components/schemas/Field' required: true security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -886,9 +818,7 @@ paths: schema: $ref: '#/components/schemas/PatchedField' security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -916,9 +846,7 @@ paths: tags: - producttypes security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '204': description: No response body @@ -936,9 +864,7 @@ paths: tags: - producttypes security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -967,9 +893,7 @@ paths: $ref: '#/components/schemas/Link' required: true security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '201': content: @@ -998,9 +922,7 @@ paths: tags: - producttypes security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -1034,9 +956,7 @@ paths: $ref: '#/components/schemas/Link' required: true security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -1069,9 +989,7 @@ paths: schema: $ref: '#/components/schemas/PatchedLink' security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -1099,9 +1017,7 @@ paths: tags: - producttypes security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '204': description: No response body @@ -1119,9 +1035,7 @@ paths: tags: - producttypes security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -1150,9 +1064,7 @@ paths: $ref: '#/components/schemas/Price' required: true security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '201': content: @@ -1181,9 +1093,7 @@ paths: tags: - producttypes security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -1217,9 +1127,7 @@ paths: $ref: '#/components/schemas/Price' required: true security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -1252,9 +1160,7 @@ paths: schema: $ref: '#/components/schemas/PatchedPrice' security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -1282,9 +1188,7 @@ paths: tags: - producttypes security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '204': description: No response body @@ -1301,9 +1205,7 @@ paths: tags: - producttypes security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -1331,9 +1233,7 @@ paths: $ref: '#/components/schemas/Question' required: true security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '201': content: @@ -1361,9 +1261,7 @@ paths: tags: - producttypes security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -1396,9 +1294,7 @@ paths: $ref: '#/components/schemas/Question' required: true security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -1430,9 +1326,7 @@ paths: schema: $ref: '#/components/schemas/PatchedQuestion' security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -1459,9 +1353,7 @@ paths: tags: - producttypes security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '204': description: No response body @@ -1471,9 +1363,7 @@ paths: tags: - tags security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -1494,9 +1384,7 @@ paths: $ref: '#/components/schemas/Tag' required: true security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '201': content: @@ -1518,9 +1406,7 @@ paths: tags: - tags security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -1547,9 +1433,7 @@ paths: $ref: '#/components/schemas/Tag' required: true security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -1575,9 +1459,7 @@ paths: schema: $ref: '#/components/schemas/PatchedTag' security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -1598,9 +1480,7 @@ paths: tags: - tags security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '204': description: No response body @@ -1610,9 +1490,7 @@ paths: tags: - tagtypes security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -1633,9 +1511,7 @@ paths: $ref: '#/components/schemas/TagType' required: true security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '201': content: @@ -1657,9 +1533,7 @@ paths: tags: - tagtypes security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -1686,9 +1560,7 @@ paths: $ref: '#/components/schemas/TagType' required: true security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -1714,9 +1586,7 @@ paths: schema: $ref: '#/components/schemas/PatchedTagType' security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '200': content: @@ -1737,9 +1607,7 @@ paths: tags: - tagtypes security: - - cookieAuth: [ ] - - basicAuth: [ ] - - { } + - tokenAuth: [ ] responses: '204': description: No response body @@ -1926,6 +1794,19 @@ components: - description - id - name + File: + type: object + properties: + id: + type: string + format: uuid + readOnly: true + file: + type: string + format: uri + required: + - file + - id Link: type: object properties: @@ -2183,6 +2064,11 @@ components: items: $ref: '#/components/schemas/Link' readOnly: true + files: + type: array + items: + $ref: '#/components/schemas/File' + readOnly: true published: type: boolean description: Whether the object is accessible through the API. @@ -2228,6 +2114,24 @@ components: type: string maxLength: 100 description: List of keywords for search + organisations: + type: array + items: + type: string + format: uuid + description: Organisations which provides this product + contacts: + type: array + items: + type: string + format: uuid + description: The contacts responsible for the product + locations: + type: array + items: + type: string + format: uuid + description: Locations where the product is available at. PatchedProductUpdate: type: object properties: @@ -2497,6 +2401,11 @@ components: items: $ref: '#/components/schemas/Link' readOnly: true + files: + type: array + items: + $ref: '#/components/schemas/File' + readOnly: true published: type: boolean description: Whether the object is accessible through the API. @@ -2542,6 +2451,24 @@ components: type: string maxLength: 100 description: List of keywords for search + organisations: + type: array + items: + type: string + format: uuid + description: Organisations which provides this product + contacts: + type: array + items: + type: string + format: uuid + description: The contacts responsible for the product + locations: + type: array + items: + type: string + format: uuid + description: Locations where the product is available at. required: - categories - category_ids @@ -2549,6 +2476,7 @@ components: - content - created_on - fields + - files - id - links - name @@ -2722,6 +2650,24 @@ components: type: string maxLength: 100 description: List of keywords for search + organisations: + type: array + items: + type: string + format: uuid + description: Organisations which provides this product + contacts: + type: array + items: + type: string + format: uuid + description: The contacts responsible for the product + locations: + type: array + items: + type: string + format: uuid + description: Locations where the product is available at. required: - content - created_on @@ -2836,10 +2782,8 @@ components: - id - name securitySchemes: - basicAuth: - type: http - scheme: basic - cookieAuth: + tokenAuth: type: apiKey - in: cookie - name: open_producten_sessionid + in: header + name: Authorization + description: Token-based authentication with required prefix "Token"