mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 21:13:36 +00:00
openapi: Add dataclass for holding article path fields.
The returned values of get_path function would be expanded soon, and defining a dataclass would make the code cleaner for returning and using the fields.
This commit is contained in:
committed by
Tim Abbott
parent
0c4330f926
commit
1375e99ae7
@@ -2,7 +2,8 @@ import os
|
||||
import random
|
||||
import re
|
||||
from collections import OrderedDict
|
||||
from typing import Any, Dict, Tuple
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, Dict, Optional, Tuple
|
||||
|
||||
from django.conf import settings
|
||||
from django.http import HttpRequest, HttpResponse, HttpResponseNotFound
|
||||
@@ -19,6 +20,14 @@ from zerver.models import Realm
|
||||
from zerver.openapi.openapi import get_endpoint_from_operationid, get_openapi_summary
|
||||
|
||||
|
||||
@dataclass
|
||||
class DocumentationArticle:
|
||||
article_path: str
|
||||
article_http_status: int
|
||||
endpoint_path: Optional[str]
|
||||
endpoint_method: Optional[str]
|
||||
|
||||
|
||||
def add_api_uri_context(context: Dict[str, Any], request: HttpRequest) -> None:
|
||||
context.update(zulip_default_context(request))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user