-
Notifications
You must be signed in to change notification settings - Fork 271
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
{format} #110
Comments
The DRF HTML views also do not respect |
i understand the context of what you are saying but what would be the concrete actions points for us? i understand that the DRF handling of those parameters is weird. what can we achieve here? if you suggest unifying the format endpoint with the regular one, i'm afraid that is not possible atm. it would require having the |
tl;dr
|
actually found a bug when i looked up the code: 6b29d1b |
Sort foo{arg} after foo/, but before foo/bar. Related to tfranzel#110
Update: Setting DRF setting
This can be seen on the APIBrowser views, there is a format UI widget, and it shows all of the formats, even if One upstream PR done, removing some unnecessary/no-longer-needed complexity: encode/django-rest-framework#7405 #123 for some of the easy improvements. Still lots to do. |
What about an setting to ignore any duplicated endpoint that only adds path And for APIs which actually want That can be done in the end-point generator, very early in the processing, eliminating what is effectively duplicate work. De-duplicating Alternatively, it can be done as post-processing helper, but that doesn't perform as well. |
Also document custom DEFAULT_GENERATOR_CLASS, and api_settings.DEFAULT_SCHEMA_CLASS . Related to tfranzel#110
Sort foo{arg} after foo/, but before foo/bar. Related to tfranzel#110
Use DRF renderer based list of possible formats, and filtered by the URLConf-based `format_suffix_patterns` formats if used. Related to tfranzel#110
Sort foo{arg} after foo/, but before foo/bar. Related to tfranzel#110
closed by #123 |
This is not fixed yet; so many aspects not done yet. |
fair enough, but we cleared most points i think. can you summarize the open points? i can see at least |
Please re-open the issue. I can not. I know how to use Open PR #124 directly relates to this. And And there are at least three other ugly bugs after that PR, described above, at least one of which requires another fix for the endpoint enumerator provided by DRF core. |
regarding the 2 unimplemented:
|
closing this issue because most points got resolved and it is unclear what is still unresolved. happy to tackle remaining issues in a new thread. several commits have addressed points that were made here:
|
Use DRF renderer based list of possible formats, and filtered by the URLConf-based `format_suffix_patterns` formats if used. Related to tfranzel/drf-spectacular#110
Sort foo{arg} after foo/, but before foo/bar. Related to tfranzel/drf-spectacular#110
{format}
currently creates a duplicate end-point with{format}
literally in the OpenAPI endpoint path, add the duplicate includes a path parameter of type 'string'.e.g.
They should not be considered distinct endpoints - effectively
/
is a added by Django'sAPPEND_SLASH = True
setting, and the duplication in the paths is caused by that and the fact thatfoo{format}
must be able to have non-/
values because it supportsfoo.json
, notfoo/.json
.The trailing
/
is just "no url format" for the same end-point, deferring to content-type header.It should be an non-mandatory enum, typically it will contain only literals
['/', '.json']
, or just['.json']
ifAPPEND_SLASH = False
.The allowable values are dynamic, depending on the view, or
DEFAULT_RENDERER_CLASSES
.{format}
also provides a URL query argument, as described at https://www.django-rest-framework.org/api-guide/format-suffixes/#query-parameter-formats . This should be included in the OpenAPI as anin:query
parameter. https://swagger.io/docs/specification/describing-parameters/#query-parameters . I have not tried url.../blah.json?format=yaml
Worth noting, DRF setting
'URL_FORMAT_OVERRIDE': None,
does not appear to prevent this{format}
behaviour (@master drf). Maybe it only inhibits the addition of the format parameter when not specified by the view. i.e. django-oscar-api explicitly has a format arg in all the view action methods. I'll dig into this aspect in the drf codebase to find out the specifics of why I dont seem to be able to turn it off. May also be some package doing monkey patching, or altering of live settings.IMO even if the settings are set up to allow
.json
, I can forsee interest in preventing it in their API docs, so that{format}
becomes a mandatory/
in the path, and theformat
path arg becomes redundant. The reason is that.json
is handy/quick for devs to pick a content type for get requests explicitly in the urlbar etc, but that isnt worth the generated OpenAPI being more complicated. Some sites might consider it it is a hidden feature that isnt supported.The text was updated successfully, but these errors were encountered: