mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
openapi: Add test to see if code exists for documented endpoints.
In addition to the test which checks to to see if each endpoint in code (urls.py) is documented in the openapi documentation (and with the right arugments). We now also have a test to see if every endpoint in the openapi documentation is a legitimate endpoint also existing in code. We do this by piggy-backing on the work done be the former test and using set operations. This method avoid the need for an extra loop and it uses set operations for additional speed and ease of reading.
This commit is contained in:
committed by
Tim Abbott
parent
718744c22d
commit
cecdec3097
@@ -1,7 +1,7 @@
|
||||
# Set of helper functions to manipulate the OpenAPI files that define our REST
|
||||
# API's specification.
|
||||
import os
|
||||
from typing import Any, Dict, List, Optional
|
||||
from typing import Any, Dict, List, Optional, Set
|
||||
|
||||
OPENAPI_SPEC_PATH = os.path.abspath(os.path.join(
|
||||
os.path.dirname(__file__),
|
||||
@@ -67,6 +67,9 @@ def get_openapi_fixture(endpoint: str, method: str,
|
||||
[response]['content']['application/json']['schema']
|
||||
['example'])
|
||||
|
||||
def get_openapi_paths() -> Set[str]:
|
||||
return set(openapi_spec.spec()['paths'].keys())
|
||||
|
||||
def get_openapi_parameters(endpoint: str,
|
||||
method: str) -> List[Dict[str, Any]]:
|
||||
return (openapi_spec.spec()['paths'][endpoint][method.lower()]['parameters'])
|
||||
|
||||
Reference in New Issue
Block a user