Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add get_schema_view() function for create Schema view for different endpoints #35

Closed
Mopsan opened this issue Apr 24, 2020 · 8 comments
Closed
Labels
enhancement New feature or request

Comments

@Mopsan
Copy link

Mopsan commented Apr 24, 2020

In drf_yasg I can create different schema views for different endpoints. Can you implement the same functionality?

from drf_yasg.views import get_schema_view
from drf_yasg import openapi

schema_view = get_schema_view(
   openapi.Info(
      title="Snippets API",
      default_version="v1",
      description="Test description",
      terms_of_service="https://www.google.com/policies/terms/",
      contact=openapi.Contact(email="contact@snippets.local"),
      license=openapi.License(name="BSD License"),
   ),
)

urlpatterns = [
   url(r"^swagger(?P<format>\.json|\.yaml)$", schema_view.without_ui(cache_timeout=0), name="schema-json"),
]
@MissiaL
Copy link
Contributor

MissiaL commented Apr 24, 2020

We are also exploring this issue here #22

@tfranzel tfranzel added the enhancement New feature or request label Apr 24, 2020
@tfranzel
Copy link
Owner

@MissiaL sry that #22 is taking so long. it is a bit more complicated than anticipated. i'm working on it and have it almost done.

@Mopsan: i believe we can accommodate that once #22 is there.

@Mopsan
Copy link
Author

Mopsan commented Apr 24, 2020

@tfranzel #22 describes the need for different versions:
Ex:
api/v1/test-app
api/v2/test-app

If need to create multiple applications with schema with the same version, how to proceed?
Ex:
api/v1/example-1-app
api/v1/example-2-app

@tfranzel
Copy link
Owner

i don't yet completely understand what you are after.

@Mopsan
Copy link
Author

Mopsan commented Apr 24, 2020

@tfranzel I want to serve multiple subsets of the API

@tfranzel
Copy link
Owner

now i understand. we need to add a parameter to SpectacularApiView. then you can manually set each subset with its own URLCONF. good catch, i'll do it.

@tfranzel
Copy link
Owner

@Mopsan that should do it for you. have a look at

urlpatterns_v1 = [url(r'^api/v1/pi', pi)]
urlpatterns_v1.append(
url(r'^api/v1/schema$', SpectacularAPIView.as_view(urlconf=urlpatterns_v1))
)
urlpatterns_v2 = [

on how to use it. the test uses it for "version" but you can use it for your case too.

@MissiaL: nowwe have at least a "ghetto" versioning until we can do it right in #22

@Mopsan
Copy link
Author

Mopsan commented Apr 26, 2020

@tfranzel ooh, that's looks good, thank you very much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants