Project

Profile

Help

Story #5574

Updated by gmbnomis over 4 years ago

Due to issue #5562, pulpcore_plugin proposes a convention for the @ref_name@ attribute of serializer @Meta@ classes. 

 The current Ideally, all serializers defined by plugins would use this convention automatically. That seems hard to achieve, since the content of @ref_name@ needs to be changed, as there is computed dynamically based on other attributes. 

 However, we can provide a (vague) recommendation class decorator @plugin_ref_name@ in pulpcore-plugin that sets @ref_name@ according to use a dot for namespaces (see for example https://github.com/OAI/OpenAPI-Specification/issues/1362). the convention. 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 defines the dot convention at a central location. 

 A plugin will have to declare its serializers like other special characters (and just removes it from the class name, capitalizing the next word). this: 

 Thus, use <app_name>.<model <pre><code class="python"> 
 class name> for @ref_name@. Ref names ("definitions" in the JSON API file) look like "file.FileRemote" then. 

 The generator creates PluginRemoteSerializer(RemoteSerializer): 

     @plugin_ref_name 
     class Meta: 
         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@. = PluginRemote 
 </code></pre> 





Back