mozilla/addons

[Bug]: TranslationSerializerField represented as string in swagger schema, though it requires a dicitonary input

Opened this issue · 2 comments

What happened?

Swagger is automatically inferring a "string" type for fields using "TranslationSerializerField" under the hood it is a CharField, but the i/o represents as a dictionary for each locale having a key/value pair.

What did you expect to happen?

We should update the swagger introspection to represent this field as a dictionary with valid local keys and string values.

Is there an existing issue for this?

  • I have searched the existing issues

┆Issue is synchronized with this Jira Task

It's possibly because under api/v3 and api/v4 Translated fields can be a string - if a lang parameter is passed it'll be a simple string in the response; and a simple string can be provided in a POST/PATCH/PUT to update, as an alternative to a dict/object.

(In api/v5 that was changed - now responses are always a dict/object, and a dict/object must always be provided for an update)

We could potentially solve this with static annotations on the serializer, however this would also imply we need to consider the version in the static definition... we could ALSO consider dropping support for v3/4 from swagger to simplify and make sure swagger is future focused.