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

I have installed drf-spectacular, and it's working great. The problem I've got is that it's a big app, and has a huge amount of endpoints and for each endpoint it repeats the /api/v1/ e.g /api/v1/jobs/. So I thought it would be a good idea to separate the pattern out i.e just /jobs #336

Closed
Fyp89 opened this issue Mar 12, 2021 · 8 comments
Labels
enhancement New feature or request fix confirmation pending issue has been fixed and confirmation from issue reporter is pending

Comments

@Fyp89
Copy link

Fyp89 commented Mar 12, 2021

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
It would be most helpful to provide a small snippet to see how the bug was provoked.

Expected behavior
A clear and concise description of what you expected to happen.

@Fyp89 Fyp89 changed the title Cannot supply patterns to avoid appending api/v1/ against each and every endpoints I have installed drf-spectacular, and it's working great. The problem I've got is that it's a big app, and has a huge amount of endpoints and for each endpoint it repeats the /api/v1/ e.g /api/v1/jobs/. So I thought it would be a good idea to separate the pattern out i.e just /jobs Mar 12, 2021
@tfranzel
Copy link
Owner

please describe the problem in more detail. "separating patterns" is could mean several things.

@Fyp89
Copy link
Author

Fyp89 commented Mar 15, 2021

please describe the problem in more detail. "separating patterns" is could mean several things.

Thanks for reaching out. I have attached screenshot for reference. I would like to not include api/v1/ when showing endpoints. For example first endpoint under jobs should be displayed /jobs/ .
Screen Shot 2021-03-15 at 1 43 44 PM
@tfranzel

@tfranzel tfranzel added the enhancement New feature or request label Mar 16, 2021
@mohannad-musleh
Copy link

@Fyp89

try to add SCHEMA_PATH_PREFIX to SPECTACULAR_SETTINGS

with this setting, all endpoints prefixed with /api/v[ANY_NUMBER] will be handled as the URL prefix

SPECTACULAR_SETTINGS = {
    # other settings
    "SCHEMA_PATH_PREFIX": r"/api/v[1-9][0-9]*"
}

@tfranzel
Copy link
Owner

that is partially correct. SCHEMA_PATH_PREFIX deals with tag extration, it does not modify the route. i'm working on a setting to remove the prefix from the route.

tfranzel added a commit that referenced this issue Mar 17, 2021
@tfranzel tfranzel added the fix confirmation pending issue has been fixed and confirmation from issue reporter is pending label Mar 17, 2021
@Fyp89
Copy link
Author

Fyp89 commented Mar 17, 2021

@mohannad-musleh Thanks for the reply. I am already using it and as @tfranzel said it works for separating endpoints by tags as you can see in the screenshot attached above the endpoints are under jobs.

@tfranzel
Copy link
Owner

@Fyp89 SCHEMA_PATH_PREFIX_TRIM is the new setting for this. set to True for removing the prefixes from the operation path.

@Fyp89
Copy link
Author

Fyp89 commented Mar 17, 2021

Just downloaded the code and checked, works like a charm. Thank you so much for this enhancement @tfranzel . How soon can this change be released ?

@Fyp89 Fyp89 closed this as completed Mar 17, 2021
@tfranzel
Copy link
Owner

this will be a y-stream release because i had to break an internal interface that some people may use. i have 2-3 more things that would need a y-stream release, which i want bundle together. likely next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fix confirmation pending issue has been fixed and confirmation from issue reporter is pending
Projects
None yet
Development

No branches or pull requests

3 participants