Support passing deprecated in the metadata dict#686
Support passing deprecated in the metadata dict#686lafrech merged 2 commits intomarshmallow-code:devfrom
deprecated in the metadata dict#686Conversation
|
Does Would it make sense to write class Schema(ma.schema):
field = ma.fields.Field(metadata={"deprecated": True})? Regarding the v2 vs. v3, we tend to not perform checks and rely on the user to do what is right. In this case, maybe it's wrong and what you propose is the way to go. If we end up doing this, perhaps we could add a |
Yes. That's exactly what this PR support to achieve: field = ma.fields.Field(metadata={"deprecated": True})Since the |
|
I understand. I just didn't find an explicit reference to this in the OpenAPI spec. It says
I didn't find an example where it is used on a single property, not the whole schema. This SO answer provides such an example. |
|
What do you think about this? def field2deprecated(self, field, **kwargs):
attributes = {}
if "deprecated" in field.metadata:
if self.openapi_version.major < 3:
attributes["x-deprecated"] = True
else:
attributes["deprecated"] = True
return attributes |
|
If we are going to add an |
|
Yeah. The only case I can think of is someone with a code base that can be used with both v2 and v3 versions dynamically. But let's not overthink this. It can always be done later if someone complains. |
I didn't add the test since it's a manual field like
description,example, andexternalDocs.By the way, it's a new field in OAS 3, should we do some special process for it? Maybe something like this:
If needed, I will add this method and the tests for it.