diff --git a/rest_framework/schemas.py b/rest_framework/schemas.py index ecfe835a90..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,14 +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) - if isinstance(model_field, models.AutoField): + 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)
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: