Skip to content

Commit

Permalink
Filter out html by default in REST API docs
Browse files Browse the repository at this point in the history
  • Loading branch information
David Davis committed Sep 18, 2019
1 parent 5cead4d commit 091ac98
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES/5009.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
By default, html in field descriptions filtered out in REST API docs unless 'include_html' is set.
5 changes: 5 additions & 0 deletions pulpcore/app/openapigenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from collections import OrderedDict

import uritemplate
from django.utils.html import strip_tags
from drf_yasg import openapi
from drf_yasg.generators import OpenAPISchemaGenerator
from drf_yasg.inspectors import SwaggerAutoSchema
Expand Down Expand Up @@ -283,6 +284,10 @@ def get_operation(self, operation_keys):
else:
operation_id = self.get_operation_id(operation_keys)
summary, description = self.get_summary_and_description()

if "include_html" not in self.request.query_params:
description = strip_tags(description)

security = self.get_security()
assert security is None or isinstance(security, list), "security must be a list of " \
"security requirement objects"
Expand Down

0 comments on commit 091ac98

Please sign in to comment.