Add url prefix to DefaultRouter and SchemaGenerator init by jsurloppe · Pull Request #4308 · encode/django-rest-framework (original) (raw)

When using a DefaultRouter as a path, the schema generated by SchemaGenerator is wrong;

router = DefaultRouter(schema_title="foobar")
url(r"^api/", include(router.urls))

The schema generated will contains path like /foobar/ and not /api/foobar/, causing wrong url being used by coreapi-cli and djando-rest-swagger.

I didn't find a proper way to retrieve the prefixed path included at the time when the schema urls are generated, so i explicitly added optional arguments.

This patch add 2 arguments, the first one to DefaultRouter: schema_prefix; the second to SchemaGenerator init: prefix.