mirror of https://github.com/zulip/zulip.git
openapi_py: Make `/events` checking strict.
Previously there was a documented_events set which provided for partial OpenAPI documentation while documentation was still going on. But since the documentation is complete now, remove it.
This commit is contained in:
parent
e7c9c55664
commit
8108acbdfd
|
@ -47,16 +47,6 @@ class OpenAPISpec():
|
||||||
self.core_data = RequestValidator(validator_spec)
|
self.core_data = RequestValidator(validator_spec)
|
||||||
self.create_regex_dict()
|
self.create_regex_dict()
|
||||||
self.last_update = os.path.getmtime(self.path)
|
self.last_update = os.path.getmtime(self.path)
|
||||||
# Form a set of all documented events
|
|
||||||
self.documented_events.clear()
|
|
||||||
schema = (self.data['paths']['/events']['get']['responses']
|
|
||||||
['200']['content']['application/json']['schema'])
|
|
||||||
for events in schema['properties']['events']['items']['oneOf']:
|
|
||||||
op_str = ':'
|
|
||||||
if 'op' in events['properties']:
|
|
||||||
op_str = f':{events["properties"]["op"]["enum"][0]}'
|
|
||||||
self.documented_events.add(events['properties']['type']['enum'][0]
|
|
||||||
+ op_str)
|
|
||||||
|
|
||||||
def create_regex_dict(self) -> None:
|
def create_regex_dict(self) -> None:
|
||||||
# Alogrithm description:
|
# Alogrithm description:
|
||||||
|
@ -132,19 +122,6 @@ class OpenAPISpec():
|
||||||
self.reload()
|
self.reload()
|
||||||
return self.core_data
|
return self.core_data
|
||||||
|
|
||||||
def get_documented_events(self) -> Set[str]:
|
|
||||||
"""Reload the OpenAPI file if it has been modified after the last time
|
|
||||||
it was read, and then return the set of documented events. Similar
|
|
||||||
to preceding functions. Used for proper access to OpenAPI objects.
|
|
||||||
"""
|
|
||||||
last_modified = os.path.getmtime(self.path)
|
|
||||||
# Using != rather than < to cover the corner case of users placing an
|
|
||||||
# earlier version than the current one
|
|
||||||
if self.last_update != last_modified:
|
|
||||||
self.reload()
|
|
||||||
return self.documented_events
|
|
||||||
|
|
||||||
|
|
||||||
class SchemaError(Exception):
|
class SchemaError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -223,8 +200,6 @@ def fix_events(content: Dict[str, Any]) -> None:
|
||||||
only zulip.yaml changes and minimal other changes. It should be removed
|
only zulip.yaml changes and minimal other changes. It should be removed
|
||||||
as soon as `/events` documentation is complete.
|
as soon as `/events` documentation is complete.
|
||||||
"""
|
"""
|
||||||
content['events'] = [event for event in content['events']
|
|
||||||
if get_event_type(event) in openapi_spec.get_documented_events()]
|
|
||||||
# 'user' is deprecated so remove its occurences from the events array
|
# 'user' is deprecated so remove its occurences from the events array
|
||||||
for event in content['events']:
|
for event in content['events']:
|
||||||
event.pop('user', None)
|
event.pop('user', None)
|
||||||
|
|
Loading…
Reference in New Issue