zulip/zerver
Zixuan James Li 9c53995830 alert_words: Migrate alert_words to use @typed_endpoint.
This demonstrates some basic use cases of the Json[...] wrapper with
@typed_endpoint.

Along with this change we extend test_openapi so that schema checking
based on function signatures will still work with this new decorator.
Pydantic's TypeAdapter supports dumping the JSON schema of any given type,
which is leveraged here to validate against our own OpenAPI definitions.
Parts of the implementation will be covered in later commits as we
migrate more functions to use @typed_endpoint.

See also:
https://docs.pydantic.dev/latest/api/type_adapter/#pydantic.type_adapter.TypeAdapter.json_schema

For the OpenAPI schema, we preprocess it mostly the same way. For the
parameter types though, we no longer need to use
get_standardized_argument_type to normalize type annotation, because
Pydantic dumps a JSON schema that is compliant with OpenAPI schema
already, which makes it a lot convenient for us to compare the types
with our OpenAPI definitions.

Do note that there are some exceptions where our definitions do not match
the generated one. For example, we use JSON to parse int and bool parameters,
but we don't mark them to use "application/json" in our definitions.
2023-09-08 08:20:17 -07:00
..
actions mypy: Upgrade mypy from 1.4.1 to 1.5.1. 2023-09-07 17:51:42 -07:00
data_import ruff: Fix PERF102 Using only the keys/values of a dict. 2023-08-07 17:23:55 -07:00
integration_fixtures/nagios
lib api: Avoid programming errors due to nested Annotated types. 2023-09-08 08:20:17 -07:00
management send_email: Broaden type of context dict. 2023-08-30 11:54:28 -07:00
migrations mypy: Upgrade mypy from 1.4.1 to 1.5.1. 2023-09-07 17:51:42 -07:00
openapi events: Send invites changes event to non-admin users also. 2023-09-07 14:21:01 -07:00
tests alert_words: Migrate alert_words to use @typed_endpoint. 2023-09-08 08:20:17 -07:00
tornado notifications: Rename 'pm' to 'dm' in 'RecipientInfoResult' dataclass. 2023-08-10 17:41:49 -07:00
transaction_tests docs: Fix typos caught by ‘typos’. 2023-09-06 18:59:05 -07:00
views alert_words: Migrate alert_words to use @typed_endpoint. 2023-09-08 08:20:17 -07:00
webhooks integrations: Add support for "Test plugin" in Sentry integration. 2023-08-22 12:09:02 -07:00
worker migration: Rename extra_data_json to extra_data in audit log models. 2023-08-16 17:18:14 -07:00
__init__.py
apps.py requirements: Upgrade Python requirements. 2023-04-03 22:39:21 -07:00
context_processors.py emails: Add corporate_enabled to context for emails. 2023-05-01 10:32:43 -07:00
decorator.py logging_util: Remove dependence on get_current_request. 2023-07-11 22:23:47 -07:00
filters.py error_notify: Remove custom email error reporting handler. 2023-07-20 11:00:09 -07:00
forms.py python: Convert translated positional {} fields to {named} fields. 2023-07-18 15:19:07 -07:00
logging_handlers.py error_notify: Remove custom email error reporting handler. 2023-07-20 11:00:09 -07:00
middleware.py middleware: Fix exception logging format on JSON views. 2023-09-06 09:14:49 -07:00
models.py models: Remove duplicate index definition for date_sent. 2023-09-07 16:44:43 -07:00
signals.py demo-orgs: Create dev environment demo organization without email. 2023-08-31 15:02:16 -07:00