OpenAPI Schema Generation and lazy strings

29 views
Skip to first unread message

Chris Vigelius

unread,
Jul 24, 2019, 4:14:51 AM7/24/19
to Django REST framework
Hello,

I'm trying to use the new generateschema command from 3.10. However it seems this does not handle lazy strings correctly.

Using the UserSerializer right from the quickstart tutorial (ModelSerializer on django.contrib.auth.models.User) yields the following schema:

openapi: 3.0.2
info:
  title: ''
  version: TODO
paths:
  /users/:
    get:
      operationId: ListUsers
      parameters: []
      responses:
        '200':
          content:
            application/json:
              schema:
                required:
                - username
                properties:
                  url:
                    type: string
                    readOnly: true
                  username:
                    type: string
                    description: &id003 !!python/object/apply:django.utils.functional._lazy_proxy_unpickle
                    - &id001 !!python/name:django.utils.translation.ugettext ''
                    - !!python/tuple
                      - Required. 150 characters or fewer. Letters, digits and @/./+/-/_
                        only.
                    - {}
                    - &id002 !!python/name:builtins.str ''


(note the garbage in username.description)

Is this a bug or am I doing something wrong?

thanks,
 chris

Carlton Gibson

unread,
Jul 24, 2019, 4:23:58 AM7/24/19
to django-res...@googlegroups.com
Hiya. Can you open a ticket? 

(I’m guessing we may need to throw in a force_text()...)

Thanks!

--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-fram...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/9a3aa24c-3174-43ee-94b8-0014e24c8e03%40googlegroups.com.

Chris Vigelius

unread,
Jul 24, 2019, 4:29:42 AM7/24/19
to Django REST framework
Sure, will do. Thanks for the quick reply!

Reply all
Reply to author
Forward
0 new messages