summary refs log tree commit diff
path: root/synapse/rest/models.py
diff options
context:
space:
mode:
authorEric Eastwood <erice@element.io>2022-08-18 16:33:22 -0500
committerEric Eastwood <erice@element.io>2022-08-18 16:33:22 -0500
commit8def7e4b4b6d0ecfb7776bf987f621e38946b50c (patch)
tree92fb7ce5f7008e7b053a36342409e1958fbdbb46 /synapse/rest/models.py
parentMerge branch 'develop' into madlittlemods/11850-migrate-to-opentelemetry (diff)
parentAdd metrics to track `/messages` response time by room size (#13545) (diff)
downloadsynapse-8def7e4b4b6d0ecfb7776bf987f621e38946b50c.tar.xz
Merge branch 'develop' into madlittlemods/11850-migrate-to-opentelemetry
Conflicts:
	poetry.lock
	synapse/federation/federation_client.py
	synapse/federation/federation_server.py
	synapse/handlers/federation.py
	synapse/handlers/federation_event.py
	synapse/logging/opentracing.py
	synapse/rest/client/room.py
	synapse/storage/controllers/persist_events.py
	synapse/storage/controllers/state.py
Diffstat (limited to 'synapse/rest/models.py')
-rw-r--r--synapse/rest/models.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/synapse/rest/models.py b/synapse/rest/models.py
new file mode 100644

index 0000000000..ac39cda8e5 --- /dev/null +++ b/synapse/rest/models.py
@@ -0,0 +1,23 @@ +from pydantic import BaseModel, Extra + + +class RequestBodyModel(BaseModel): + """A custom version of Pydantic's BaseModel which + + - ignores unknown fields and + - does not allow fields to be overwritten after construction, + + but otherwise uses Pydantic's default behaviour. + + Ignoring unknown fields is a useful default. It means that clients can provide + unstable field not known to the server without the request being refused outright. + + Subclassing in this way is recommended by + https://pydantic-docs.helpmanual.io/usage/model_config/#change-behaviour-globally + """ + + class Config: + # By default, ignore fields that we don't recognise. + extra = Extra.ignore + # By default, don't allow fields to be reassigned after parsing. + allow_mutation = False