From b1595beb14133aa45db016431e5c5922da72dfae Mon Sep 17 00:00:00 2001 From: maxime Date: Wed, 2 Aug 2023 13:29:57 +0200 Subject: [PATCH] [tests] write a schema component for dummy_domain for example --- tests/dummy_domain/__init__.py | 19 ++++++++++++++++++- .../routers/abc/pinnochio/__init__.py | 14 +++++++++++--- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/tests/dummy_domain/__init__.py b/tests/dummy_domain/__init__.py index 2ab3c71..00e185f 100644 --- a/tests/dummy_domain/__init__.py +++ b/tests/dummy_domain/__init__.py @@ -6,5 +6,22 @@ domain = { 'id': '8b88e60a625369235b36c2d6d70756a0c02c1c7fb169fcee6dc820bcf9723f5a', 'deps': ( ('halfapi', '=={}'.format(halfapi_version)), - ) + ), + 'schema_components': { + 'schemas': { + 'Pinnochio': { + 'type': 'object', + 'required': { + 'id', + 'name', + 'nose_size' + }, + 'properties': { + 'id': {'type': 'string'}, + 'name': {'type': 'string'}, + 'nose_size': {'type': 'number'} + } + } + } + } } diff --git a/tests/dummy_domain/routers/abc/pinnochio/__init__.py b/tests/dummy_domain/routers/abc/pinnochio/__init__.py index e03171a..e25431b 100644 --- a/tests/dummy_domain/routers/abc/pinnochio/__init__.py +++ b/tests/dummy_domain/routers/abc/pinnochio/__init__.py @@ -1,13 +1,21 @@ +from uuid import uuid4 from halfapi.lib import acl ACLS = { 'GET' : [{'acl':acl.public}] } def get(): """ - description: - Not implemented + description: The pinnochio guy responses: 200: description: test response + content: + application/json: + schema: + $ref: "#/components/schemas/Pinnochio" """ - raise NotImplementedError + return { + 'id': str(uuid4()), + 'name': 'pinnochio', + 'nose_size': 42 + }