master branch of Django REST framework.class ExampleViewSet(ModelViewSet):
@detail_route(methods=['put', 'post'])
def custom_action(self, request, pk):
pass
schema_generator = SchemaGenerator(title='Restrictive API')
schema = schema_generator.get_schema()
Both PUT and POST methods in resulted schema.
Only one method in generated schema.
Problem is that in suggested coreapi document structure used dict with actions as values and links as values.
It could be solved by changing action key in schema document for detail_view methods. Or by using list of links as values. I myself don't see full problem scope - just my minor issue.
And such changes could lead to major consequences - so it's up to author to decide.
We're constrained to 2 levels deep if we want to support swagger, so category/action.
But yup I'm looking at this for the 3.4.4 release (final remaining issue)
It's not fixed. Coreapi document generated by schema generator still use dict with actions as keys and coreapi links as value. So in case of multiple http methods per action it didn't fit in schema.
Test case provided.
I also happens if you have 2 similar actions. ex:
class ExampleViewSet1(ModelViewSet):
@detail_route(methods=['post'])
def custom_action(self, request, pk):
pass
class ExampleViewSet2(ModelViewSet):
@detail_route(methods=['post'])
def custom_action(self, request, pk):
pass
@kmmbvnr I was unable to reproduce your case. Even write a simple test for it - see #4400 tests.test_schemas.TestSchemaGenerator.test_similar_actions
Please provide more info on how you register viewsets in urlconf, what serializers/models used etc.
Most helpful comment
It's not fixed. Coreapi document generated by schema generator still use dict with actions as keys and coreapi links as value. So in case of multiple http methods per action it didn't fit in schema.
Test case provided.