0

I use django and swagger. I write doc string in my django function like this :

/?first_name__icontains=saeed&age__gte=20. 

But swagger show them like this

enter image description here

how can I escape characters like & in django and swagger?

Edit:

My code in docstring of a django view enter image description here

Result in Swagger enter image description here

mastisa
  • 1,875
  • 3
  • 21
  • 39
  • Where exactly is this string used in your code? Please post your code. Can you also post a larger screenshot of Swagger UI that shows that string in context? The mode details the easier it will be for someone to help you. – Helen May 16 '18 at 10:36
  • I update the question, thanks for your notice. – mastisa May 16 '18 at 10:46
  • Sorry but there's still not enough details... From my understanding, it looks like you have a `description` with Markdown markup and that line is supposed to be formatted as a code (using 4-space indent) but Swagger UI renders the line incorrectly. Is this what your question is about? – Helen May 16 '18 at 11:04
  • I type & in my doc string but swagger show &. I think & is a special character in swagger but I don't know how to escape it. – mastisa May 16 '18 at 11:12

1 Answers1

1

& being rendered as & in code blocks is a bug in Swagger UI 2.x which was fixed in UI 3.3.0: https://github.com/swagger-api/swagger-ui/issues/2700

You need to update your Swagger UI version.

Helen
  • 87,344
  • 17
  • 243
  • 314
  • I use django rest swagger, what can I do for that? – mastisa May 19 '18 at 05:23
  • @SaeedBabashahi Try the latest version of django-rest-swagger ([2.2.0](https://github.com/marcgibbons/django-rest-swagger/releases/tag/2.2.0)). It includes Swagger UI 3.x. – Helen May 19 '18 at 11:05
  • Thanks, I check it but it has a bug with JWT authorization. – mastisa May 20 '18 at 05:02