From 30c4b08519cec6b134f100f69dfbd5da5318c539 Mon Sep 17 00:00:00 2001 From: ANDRE Simon Date: Fri, 6 Oct 2023 13:54:50 +0200 Subject: [PATCH] [FIX] try fix doc --- .../doc/account_app/endpoints/docstrings.json | 2 +- .../doc/account_app/schemas/docstrings.json | 86 +------------------ .../utilities/email/docstrings.json | 2 +- .../utilities/token/docstrings.json | 2 +- .../doc/base_app/schemas/docstrings.json | 53 +----------- 5 files changed, 5 insertions(+), 140 deletions(-) diff --git a/docsite/public/doc/account_app/endpoints/docstrings.json b/docsite/public/doc/account_app/endpoints/docstrings.json index 6d61c89..e87c3c1 100644 --- a/docsite/public/doc/account_app/endpoints/docstrings.json +++ b/docsite/public/doc/account_app/endpoints/docstrings.json @@ -1 +1 @@ -{"register_save":{"funcdef":"def register_save(\n\trequest: HttpRequest,\n\tdata: RegisterFormContract\n)","description":"Register a user from a registration form","long_description":"Endpoint url: /api/account/register","example":{"code":"# example of valid payload\n{\n \"name\": \"John Doe\",\n \"email\": \"mymail@example.com\",\n \"password1\": \"xxxzzzxxx\",\n \"password2\": \"xxxzzzxxx\",\n}\n\n# example of form error payload return with a 422 status code\n{\n \"errors\": {\n 'password2': [\n {\n 'message': 'The two password fields didn’t match.',\n 'code': 'password_mismatch'\n }\n ]\n }\n}","is_executable":false,"description":""},"params":{"request":{"description":"the django http request object","type":"HttpRequest","default":null},"data":{"description":"the form json payload","type":"RegisterFormContract","default":null}},"raises":[],"returns":{"name":null,"type":"HttpResponse"}},"activate_save":{"funcdef":"def activate_save(\n\trequest: HttpRequest,\n\ttoken: str\n) -> Tuple[int, None | MsgResponseContract]","description":"Activate a user from a token","long_description":"Endpoint url: /api/account/activate/{token}

User has clicked on link in an email with an activation token, and we activate the user if the token is valid","example":{"code":"# example of an activation refused with a 401 http status code\n{\n \"message\": \"Account activation refused\"\n}","is_executable":false,"description":""},"params":{"request":{"description":"the django http request object","type":"HttpRequest","default":null},"token":{"description":"the token","type":"str","default":null}},"raises":[],"returns":{"name":null,"type":"Tuple[int, None | MsgResponseContract]"}},"authlogin":{"funcdef":"def authlogin(\n\trequest: HttpRequest,\n\tdata: LoginFormContract\n) -> Tuple[int, None | FormInvalidResponseContract | MsgResponseContract]","description":"Login a user from a username and password payload","long_description":"Endpoint url: /api/account/login","example":null,"params":{"request":{"description":"the django http request object","type":"HttpRequest","default":null},"data":{"description":"the username and password payload","type":"LoginFormContract","default":null}},"raises":[],"returns":{"name":null,"type":"Tuple[int, None | FormInvalidResponseContract | MsgResponseContract]"}},"authlogout":{"funcdef":"def authlogout(\n\trequest: HttpRequest\n) -> Tuple[int, None]","description":"Logout a user","long_description":"Endpoint url: /api/account/logout","example":null,"params":{"request":{"description":"the django http request object","type":"HttpRequest","default":null}},"raises":[],"returns":{"name":null,"type":"Tuple[int, None]"}},"global_state":{"funcdef":"def global_state(\n\trequest: HttpRequest\n) -> Tuple[int, StateContract]","description":"Returns info on user state and set a csrf token","long_description":"Endpoint url: /api/account/state","example":null,"params":{"request":{"description":"the django http request object","type":"HttpRequest","default":null}},"raises":[],"returns":{"name":null,"type":"Tuple[int, StateContract]"}}} \ No newline at end of file +{"register_save": {"lang": "python", "funcdef": "def register_save(\n\trequest: HttpRequest,\n\tdata: RegisterFormContract\n)", "description": "Register a user from a registration form", "long_description": "Endpoint url: /api/account/register", "example": {"code": "# example of valid payload\n{\n \"name\": \"John Doe\",\n \"email\": \"mymail@example.com\",\n \"password1\": \"xxxzzzxxx\",\n \"password2\": \"xxxzzzxxx\",\n}\n\n# example of form error payload return with a 422 status code\n{\n \"errors\": {\n 'password2': [\n {\n 'message': 'The two password fields didn\u2019t match.',\n 'code': 'password_mismatch'\n }\n ]\n }\n}", "is_executable": false, "description": ""}, "params": {"request": {"description": "the django http request object", "type": "HttpRequest", "default": null}, "data": {"description": "the form json payload", "type": "RegisterFormContract", "default": null}}, "raises": [], "returns": {"description": "an http response", "type": "HttpResponse"}}, "activate_save": {"lang": "python", "funcdef": "def activate_save(\n\trequest: HttpRequest,\n\ttoken: str\n) -> Tuple[int, None | SkiiMsgContract]", "description": "Activate a user from a token", "long_description": "Endpoint url: /api/account/activate/{token}

User has clicked on link in an email with an activation token, and we activate the user if the token is valid", "example": {"code": "# example of an activation refused with a 401 http status code\n{\n \"message\": \"Account activation refused\"\n}", "is_executable": false, "description": ""}, "params": {"request": {"description": "the django http request object", "type": "HttpRequest", "default": null}, "token": {"description": "the token", "type": "str", "default": null}}, "raises": [], "returns": {"description": "a 204 empty or a 401 with a message if the token is invalid", "type": "Tuple[int, None | MsgResponseContract]"}}, "authlogin": {"lang": "python", "funcdef": "def authlogin(\n\trequest: HttpRequest,\n\tdata: LoginFormContract\n) -> Tuple[int, None | FormInvalidResponseContract | SkiiMsgContract]", "description": "Login a user from a username and password payload", "long_description": "Endpoint url: /api/account/login", "example": null, "params": {"request": {"description": "the django http request object", "type": "HttpRequest", "default": null}, "data": {"description": "the username and password payload", "type": "LoginFormContract", "default": null}}, "raises": [], "returns": {"description": "the http status code and the data payload", "type": "Tuple[int, None | FormInvalidResponseContract | MsgResponseContract]"}}, "authlogout": {"lang": "python", "funcdef": "def authlogout(\n\trequest: HttpRequest\n) -> Tuple[int, None]", "description": "Logout a user", "long_description": "Endpoint url: /api/account/logout", "example": null, "params": {"request": {"description": "the django http request object", "type": "HttpRequest", "default": null}}, "raises": [], "returns": {"description": "the http status code and None", "type": "Tuple[int, None]"}}, "global_state": {"lang": "python", "funcdef": "def global_state(\n\trequest: HttpRequest\n) -> Tuple[int, StateContract]", "description": "Returns info on user state and set a csrf token", "long_description": "Endpoint url: /api/account/state", "example": null, "params": {"request": {"description": "the django http request object", "type": "HttpRequest", "default": null}}, "raises": [], "returns": {"description": "the http status code and the data payload", "type": "Tuple[int, StateContract]"}}} \ No newline at end of file diff --git a/docsite/public/doc/account_app/schemas/docstrings.json b/docsite/public/doc/account_app/schemas/docstrings.json index 0635218..9514cf4 100644 --- a/docsite/public/doc/account_app/schemas/docstrings.json +++ b/docsite/public/doc/account_app/schemas/docstrings.json @@ -1,85 +1 @@ -{ - "LoginFormContract": { - "funcdef": "class LoginFormContract(Schema)", - "description": "Incoming data from login form post", - "long_description": null, - "example": { - "code": "{\n \"username\": \"lamdajoe\",\n \"password\": \"xxx48dioEjni\",\n}", - "is_executable": false, - "description": "" - }, - "params": { - "username": { - "description": "the username", - "type": "str | None", - "default": null - }, - "password": { - "description": "the password", - "type": "str | None", - "default": null - } - }, - "raises": [], - "returns": null - }, - "RegisterFormContract": { - "funcdef": "class RegisterFormContract(Schema)", - "description": "Incoming data from registration form post", - "long_description": null, - "example": { - "code": "{\n \"name\": \"lamdajoe\",\n \"email\": \"amail@example.com\",\n \"password1\": \"xxx48dioEjni\",\n \"password2\": \"xxx48dioEjni\",\n}", - "is_executable": false, - "description": "" - }, - "params": { - "name": { - "description": "the user full name", - "type": "str | None", - "default": null - }, - "email": { - "description": "the password", - "type": "str | None", - "default": null - }, - "password1": { - "description": "the password confirmation", - "type": "str | None", - "default": null - } - }, - "raises": [], - "returns": null - }, - "StateContract": { - "funcdef": "class StateContract(Schema)", - "description": "Account state data", - "long_description": "This is returned by the /api/state endpoint called
when the frontend app mounts to get the state of the
user", - "example": { - "code": "{\n \"is_connected\": True,\n \"username\": \"johndoe\",\n}", - "is_executable": false, - "description": "" - }, - "params": { - "is_connected": { - "description": "if the user is connected or not", - "type": "bool", - "default": null - }, - "username": { - "description": "the user username", - "type": "str", - "default": null - } - }, - "raises": [], - "returns": null, - "extra_examples": [ - { - "code": "from apps.account.schemas import StateContract\n\n# inspect the contract\nprops = StateContract.schema()[\"properties\"]\nfor key in props:\n print(key, \"prop is of type\", props[key][\"type\"])\n\n# create a contract\nuser_state_data = {\n \"is_connected\": True,\n \"username\": \"johndoe\",\n}\nstate_contract = StateContract(**user_state_data)\nprint(\"The contract json payload:\", str(state_contract.json(indent=2)))\n", - "is_executable": true - } - ] - } -} \ No newline at end of file +{"LoginFormContract": {"lang": "python", "funcdef": "class LoginFormContract(Schema)", "description": "Incoming data from login form post", "long_description": null, "example": {"code": "{\n \"username\": \"lamdajoe\",\n \"password\": \"xxx48dioEjni\",\n}", "is_executable": false, "description": ""}, "params": {"username": {"description": "the username", "type": "str | None", "default": null}, "password": {"description": "the password", "type": "str | None", "default": null}}, "raises": [], "returns": null}, "RegisterFormContract": {"lang": "python", "funcdef": "class RegisterFormContract(Schema)", "description": "Incoming data from registration form post", "long_description": null, "example": {"code": "{\n \"name\": \"lamdajoe\",\n \"email\": \"amail@example.com\",\n \"password1\": \"xxx48dioEjni\",\n \"password2\": \"xxx48dioEjni\",\n}", "is_executable": false, "description": ""}, "params": {"name": {"description": "the user full name", "type": "str | None", "default": null}, "email": {"description": "the password", "type": "str | None", "default": null}, "password1": {"description": "the password confirmation", "type": "str | None", "default": null}}, "raises": [], "returns": null}, "StateContract": {"lang": "python", "funcdef": "class StateContract(Schema)", "description": "Account state data", "long_description": "This is returned by the /api/state endpoint called\nwhen the frontend app mounts to get the state of the\nuser", "example": {"code": "{\n \"is_connected\": True,\n \"username\": \"johndoe\",\n}", "is_executable": false, "description": ""}, "params": {"is_connected": {"description": "if the user is connected or not", "type": "bool", "default": null}, "username": {"description": "the user username", "type": "str", "default": null}}, "raises": [], "returns": null}} \ No newline at end of file diff --git a/docsite/public/doc/account_app/utilities/email/docstrings.json b/docsite/public/doc/account_app/utilities/email/docstrings.json index dfbf6cc..ff6d333 100644 --- a/docsite/public/doc/account_app/utilities/email/docstrings.json +++ b/docsite/public/doc/account_app/utilities/email/docstrings.json @@ -1 +1 @@ -{"email_message":{"funcdef":"def email_message(\n\tmessage: str,\n\tsubject: str,\n\tto_email: str\n) -> int","description":"Send an email message","long_description":null,"example":null,"params":{"message":{"description":"the email body message","type":"str","default":null},"subject":{"description":"the email subject","type":"str","default":null},"to_email":{"description":"the email to send to","type":"str","default":null}},"raises":[],"returns":{"name":null,"type":"int"}},"email_activation_token":{"funcdef":"def email_activation_token(\n\trequest: HttpRequest,\n\tuser: AbstractBaseUser,\n\tto_email: str,\n\tsubject: str,\n\ttemplate: List[str] | str\n) -> int","description":"Send an email activation message containing a token","long_description":null,"example":null,"params":{"request":{"description":"the Django http request","type":"HttpRequest","default":null},"user":{"description":"a Django user","type":"AbstractBaseUser","default":null},"to_email":{"description":"the email to send to","type":"str","default":null},"subject":{"description":"the email subject","type":"str","default":null},"template":{"description":"the template to use to render the mail","type":"List[str] | str","default":null}},"raises":[],"returns":{"name":null,"type":"int"}}} \ No newline at end of file +{"email_message": {"lang": "python", "funcdef": "def email_message(\n\tmessage: str,\n\tsubject: str,\n\tto_email: str\n) -> int", "description": "Send an email message", "long_description": null, "example": null, "params": {"message": {"description": "the email body message", "type": "str", "default": null}, "subject": {"description": "the email subject", "type": "str", "default": null}, "to_email": {"description": "the email to send to", "type": "str", "default": null}}, "raises": [], "returns": {"description": "a status", "type": "int"}}, "email_activation_token": {"lang": "python", "funcdef": "def email_activation_token(\n\trequest: HttpRequest,\n\tuser: AbstractBaseUser,\n\tto_email: str,\n\tsubject: str,\n\ttemplate: List[str] | str\n) -> int", "description": "Send an email activation message containing a token", "long_description": null, "example": null, "params": {"request": {"description": "the Django http request", "type": "HttpRequest", "default": null}, "user": {"description": "a Django user", "type": "AbstractBaseUser", "default": null}, "to_email": {"description": "the email to send to", "type": "str", "default": null}, "subject": {"description": "the email subject", "type": "str", "default": null}, "template": {"description": "the template to use to render the mail", "type": "List[str] | str", "default": null}}, "raises": [], "returns": {"description": "a status", "type": "int"}}} \ No newline at end of file diff --git a/docsite/public/doc/account_app/utilities/token/docstrings.json b/docsite/public/doc/account_app/utilities/token/docstrings.json index 717db0c..625f0bd 100644 --- a/docsite/public/doc/account_app/utilities/token/docstrings.json +++ b/docsite/public/doc/account_app/utilities/token/docstrings.json @@ -1 +1 @@ -{"decode_token":{"funcdef":"def decode_token(\n\ttoken: str\n) -> Tuple[bool, str]","description":"Decode and validate an activation token","long_description":null,"example":null,"params":{"token":{"description":"the token","type":"str","default":null}},"raises":[],"returns":{"name":null,"type":"Tuple[bool, str]"}}} \ No newline at end of file +{"decode_token": {"lang": "python", "funcdef": "def decode_token(\n\ttoken: str\n) -> Tuple[bool, str]", "description": "Decode and validate an activation token", "long_description": null, "example": null, "params": {"token": {"description": "the token", "type": "str", "default": null}}, "raises": [], "returns": {"description": "is the token valid and the user email", "type": "Tuple[bool, str]"}}, "encode_token": {"lang": "python", "funcdef": "def encode_token(\n\temail: str\n) -> str", "description": "Encode a token", "long_description": null, "example": null, "params": {"email": {"description": "the email to encode", "type": "str", "default": null}}, "raises": [], "returns": {"description": "the encoded token", "type": "str"}}} \ No newline at end of file diff --git a/docsite/public/doc/base_app/schemas/docstrings.json b/docsite/public/doc/base_app/schemas/docstrings.json index 7fa7b15..89fa464 100644 --- a/docsite/public/doc/base_app/schemas/docstrings.json +++ b/docsite/public/doc/base_app/schemas/docstrings.json @@ -1,52 +1 @@ -{ - "MsgResponseContract": { - "funcdef": "class MsgResponseContract(Schema)", - "description": "A response with a text message", - "long_description": null, - "example": { - "code": "{\n \"message\": \"The message\"\n}", - "is_executable": false, - "description": "" - }, - "params": { - "message": { - "description": "the text message", - "type": "str", - "default": null - } - }, - "raises": [], - "returns": null, - "extra_examples": [ - { - "code": "from apps.base.schemas import MsgResponseContract\n\n# inspect the contract\nprops = MsgResponseContract.schema()[\"properties\"]\nfor key in props:\n print(key, \"prop is of type\", props[key][\"type\"])\n\n# create a contract\ninstance = {\n \"message\": \"A message\",\n}\ninstance_contract = MsgResponseContract(**instance)\nprint(\"The contract json payload:\", str(instance_contract.json(indent=2)))\n", - "is_executable": true - } - ] - }, - "FormInvalidResponseContract": { - "funcdef": "class FormInvalidResponseContract(Schema)", - "description": "Form errors dict provided by Django from form validation", - "long_description": null, - "example": { - "code": "{\n \"errors\": {\n 'password2': [\n {\n 'message': 'The two password fields didn’t match.',\n 'code': 'password_mismatch'\n }\n ]\n }\n}", - "is_executable": false, - "description": "" - }, - "params": { - "errors": { - "description": "a Django form errors dict", - "type": "Dict[str, List[Dict[str, Any]]]", - "default": null - } - }, - "raises": [], - "returns": null, - "extra_examples": [ - { - "code": "from django.contrib.auth.forms import UserCreationForm\nfrom apps.base.schemas import FormInvalidResponseContract\n\n# inspect the contract\nprops = FormInvalidResponseContract.schema()[\"properties\"]\nfor key in props:\n print(key, \"prop is of type\", props[key][\"type\"])\n\n# create a contract\ndata = {\n \"username\": \"john\",\n \"password1\": \"foo\",\n \"password2\": \"bar\",\n}\nform = UserCreationForm(data=data)\nprint(\"The Django form has errors:\")\nprint(form.errors)\njson_errs = form.errors.get_json_data(escape_html=True)\ninstance_contract = FormInvalidResponseContract(errors=json_errs)\nstr(instance_contract)\n", - "is_executable": true - } - ] - } -} \ No newline at end of file +{"FormInvalidResponseContract": {"lang": "python", "funcdef": "class FormInvalidResponseContract(Schema)", "description": "Form errors dict provided by Django from form validation", "long_description": null, "example": {"code": "{\n \"errors\": {\n 'password2': [\n {\n 'message': 'The two password fields didn\u2019t match.',\n 'code': 'password_mismatch'\n }\n ]\n }\n}", "is_executable": false, "description": ""}, "params": {"errors": {"description": "a Django form errors dict", "type": "Dict[str, List[Dict[str, Any]]]", "default": null}}, "raises": [], "returns": null}} \ No newline at end of file