Skip to content

Commit

Permalink
Problem: OpenAPI schema can't be generated for some plugins
Browse files Browse the repository at this point in the history
Solution: generate schema from Views without querysets

This patch also skips generating schema for views without models associated with them.

fixes: #4794
https://pulp.plan.io/issues/4794
  • Loading branch information
dkliban committed May 17, 2019
1 parent 42c1d62 commit 8d80fc9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pulpcore/app/openapigenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,14 @@ def get_paths(self, endpoints, components, request, public):
resource_path = '%s}/' % path.rsplit(sep='}', maxsplit=1)[0]
resource_other_path = self.get_resource_from_path(path)
if resource_other_path in endpoints:
resource_model = endpoints[resource_other_path][0].queryset.model
view = endpoints[resource_other_path][0]
if not hasattr(view, 'queryset') or view.queryset is None:
if hasattr(view, 'model'):
resource_model = view.model
else:
continue
else:
resource_model = view.queryset.model
resource_name = self.get_parameter_name(resource_model)
param_name = self.get_parameter_slug_from_model(resource_model)
if resource_path in resources:
Expand Down

0 comments on commit 8d80fc9

Please sign in to comment.