-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #487 from hinashi/feature/auto_generate/custom_view
Added DRF Spectacular settings for customview
- Loading branch information
Showing
8 changed files
with
42 additions
and
622 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# These methods are used for filtering API endpoints to generate | ||
# OpenAPI schema using drf-spectacular. | ||
# (c.f. https://drf-spectacular.readthedocs.io/en/latest/settings.html) | ||
|
||
def exclude_customview_hook(endpoints): | ||
"""This excludes API endpoints of custom-view's ones. Because it's not always | ||
necessary to generage custom-view's OpenAPI schema. | ||
""" | ||
result = [] | ||
for (path, path_regex, method, callback) in endpoints: | ||
if "/custom/" not in path: | ||
result.append((path, path_regex, method, callback)) | ||
return result | ||
|
||
|
||
def filter_apiv2_hook(endpoints): | ||
"""This excludes API endpoints for AirOne API(v1). React views refer to only | ||
AirOne API(v2). So it's not necessary to generate API(v1)'s OpenAPI schema. | ||
""" | ||
result = [] | ||
for (path, path_regex, method, callback) in endpoints: | ||
if "/api/v2/" in path: | ||
result.append((path, path_regex, method, callback)) | ||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
.openapi-generator-ignore | ||
apis/AclApi.ts | ||
apis/ApiApi.ts | ||
apis/EntityApi.ts | ||
apis/EntryApi.ts | ||
apis/GroupApi.ts | ||
|
Oops, something went wrong.