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

Wrong Base URL: localhost #872

Open
navxio opened this issue Oct 26, 2023 · 2 comments
Open

Wrong Base URL: localhost #872

navxio opened this issue Oct 26, 2023 · 2 comments

Comments

@navxio
Copy link

navxio commented Oct 26, 2023

Bug Report

Description

the base url is evaluated as localhost
[ Base URL: localhost/v1 ]

Is this a regression?

Can't say

Minimal Reproduction

Use drf-yasg 1.27.x with django 4.1.12 and drf ^3.14

Your Environment

schema_view = get_schema_view(
    openapi.Info(
        title =  "my API",
        default_version = 'v1',
        description = 'my api description',
        terms_of_service = "https://www.google.com/policies/terms/",
        contact = openapi.Contact(email = 'user@example.com'),
        license = openapi.License(name = 'BSD License'),
    ),
    public=True,
    permission_classes=(permissions.AllowAny,),
)

urlpatterns = [
...
    path('docs/', schema_view.with_ui('swagger', cache_timeout=0),
         name='schema-swagger-ui'),
...
]

#my_app/urls.py

SWAGGER_SETTINGS = {
    "DEFAULT_API_URL": "https://mydomain.tld/v1"
}


@mburke05
Copy link

yea i'm experiencing this too, drf-yasg == 1.21.7, django == 4.0.5, drf 3.13.1

curious if you had a fix?

@hungddit
Copy link

I fixed by adding url in get_schema_view function:

schema_view = get_schema_view(
openapi.Info(
title = "my API",
default_version = 'v1',
description = 'my api description',
terms_of_service = "https://www.google.com/policies/terms/",
contact = openapi.Contact(email = 'user@example.com'),
license = openapi.License(name = 'BSD License'),
),
public=True,
permission_classes=(permissions.AllowAny,),

url: https://your-domain/api-url

)

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

No branches or pull requests

3 participants