kitware-resonant / cookiecutter-resonant

Apache License 2.0
11 stars 6 forks source link

Add swagger #170

Closed banesullivan closed 2 years ago

banesullivan commented 2 years ago

Swagger is incredibly useful and should be a default feature of the cookie-cutter IMO

It's simply adding the following to urls.py:

from django.urls import re_path

urlpatterns += [
    re_path(
        r'^swagger(?P<format>\.json|\.yaml)$',
        schema_view.without_ui(cache_timeout=0),
        name='schema-json',
    ),
    path('swagger/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
    path('redoc/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
]
brianhelba commented 2 years ago

I'm not understanding, what is the problem with the existing code: https://github.com/girder/cookiecutter-girder-4/blob/8974eb64a7ff4742d23b2d5eacbc4deebc90ab91/%7B%7B%20cookiecutter.project_slug%20%7D%7D/%7B%7B%20cookiecutter.pkg_name%20%7D%7D/urls.py#L34 ?

banesullivan commented 2 years ago

I totally missed that... 🤦🏻‍♂️

I ran into this while spinning up a new Django Project and must have missed that it was hosted at api/docs/swagger/ instead of just swagger/