From c7e2d1d9760e543810130b058f2866486e7d9f98 Mon Sep 17 00:00:00 2001 From: Dariusz Czech Date: Mon, 20 Mar 2017 22:21:07 +0100 Subject: [PATCH 1/3] Do not hint BigAutoField as integer (outside of range) --- rest_framework/schemas.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rest_framework/schemas.py b/rest_framework/schemas.py index ecfe835a90..802942d040 100644 --- a/rest_framework/schemas.py +++ b/rest_framework/schemas.py @@ -1,6 +1,6 @@ -import re from collections import OrderedDict from importlib import import_module +import re from django.conf import settings from django.contrib.admindocs.views import simplify_regex @@ -23,6 +23,7 @@ from rest_framework.utils.model_meta import _get_pk from rest_framework.views import APIView + header_regex = re.compile('^[a-zA-Z][0-9A-Za-z_]*:') @@ -541,7 +542,8 @@ def get_path_fields(self, path, method, view): elif model_field is not None and model_field.primary_key: description = get_pk_description(model, model_field) - if isinstance(model_field, models.AutoField): + # BigAutoField is outside of Integer range + if isinstance(model_field, models.AutoField) and not isinstance(model_field, models.BigAutoField): schema_cls = coreschema.Integer field = coreapi.Field( From 9074e3e478e00974d17013d7eabb41f7ee38c197 Mon Sep 17 00:00:00 2001 From: Dariusz Czech Date: Tue, 21 Mar 2017 08:40:59 +0100 Subject: [PATCH 2/3] restored original formatting --- rest_framework/schemas.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rest_framework/schemas.py b/rest_framework/schemas.py index 802942d040..f89f347ac3 100644 --- a/rest_framework/schemas.py +++ b/rest_framework/schemas.py @@ -1,6 +1,6 @@ +import re from collections import OrderedDict from importlib import import_module -import re from django.conf import settings from django.contrib.admindocs.views import simplify_regex @@ -23,7 +23,6 @@ from rest_framework.utils.model_meta import _get_pk from rest_framework.views import APIView - header_regex = re.compile('^[a-zA-Z][0-9A-Za-z_]*:') From 54d0901f381b9fdd95dfeb5b9b26f6839eaba433 Mon Sep 17 00:00:00 2001 From: Dariusz Czech Date: Tue, 21 Mar 2017 15:15:20 +0100 Subject: [PATCH 3/3] Leave parameters with regex pattern as String --- rest_framework/schemas.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/rest_framework/schemas.py b/rest_framework/schemas.py index f89f347ac3..c15ed0bfd2 100644 --- a/rest_framework/schemas.py +++ b/rest_framework/schemas.py @@ -526,6 +526,7 @@ def get_path_fields(self, path, method, view): title = '' description = '' schema_cls = coreschema.String + kwargs = {} if model is not None: # Attempt to infer a field description if possible. try: @@ -541,15 +542,16 @@ def get_path_fields(self, path, method, view): elif model_field is not None and model_field.primary_key: description = get_pk_description(model, model_field) - # BigAutoField is outside of Integer range - if isinstance(model_field, models.AutoField) and not isinstance(model_field, models.BigAutoField): + if hasattr(view, 'lookup_value_regex') and view.lookup_field == variable: + kwargs['pattern'] = view.lookup_value_regex + elif isinstance(model_field, models.AutoField): schema_cls = coreschema.Integer field = coreapi.Field( name=variable, location='path', required=True, - schema=schema_cls(title=title, description=description) + schema=schema_cls(title=title, description=description, **kwargs) ) fields.append(field) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy