Story #5574
closedProvide an easy to use way to ensure the ref_name attribute convention
100%
Description
Due to issue #5562, pulpcore_plugin proposes a convention for the ref_name
attribute of serializer Meta
classes.
The current convention needs to be changed, as there is a (vague) recommendation to use a dot for namespaces (see for example https://github.com/OAI/OpenAPI-Specification/issues/1362). This is supported in some tools, but neither in swagger codegen, see https://github.com/swagger-api/swagger-codegen/issues/7326 nor in OpenAPITools/openapi-generator. openapi-generator handles the dot like other special characters (and just removes it from the class name, capitalizing the next word).
Thus, use <app_name>.<model class name> for ref_name
. Ref names ("definitions" in the JSON API file) look like "file.FileRemote" then.
The generator creates model classes like "FileFileRemote". For models defined by core, we do not introduce a separate namespace (core.
) but leave them as they are today.
For Modelserializers
derived from pulpcore's ModelSerializer
we can provide a proper default for ref_name
.
Set default
ref_name
attribute for a ModelSerializers'sMeta
class.Use the init_subclass method added in Python 3.6 to customize subclasses of pulpcore's ModelSerializer class.
If it is not yet defined, set the
Meta.ref_name
attribute according to the best practice established within Pulp ('.').closes #5574 https://pulp.plan.io/issues/5574