@@ -164,8 +164,7 @@ appropriate Core API `Link` object for the view, request method and path:
164
164
auto_schema = view.schema
165
165
coreapi_link = auto_schema.get_link(...)
166
166
167
-
168
- (Aside: In compiling the schema, ` SchemaGenerator ` calls ` view.schema.get_link() ` for
167
+ (In compiling the schema, ` SchemaGenerator ` calls ` view.schema.get_link() ` for
169
168
each view, allowed method and path.)
170
169
171
170
To customise the ` Link ` generation you may:
@@ -178,9 +177,9 @@ To customise the `Link` generation you may:
178
177
class CustomView(APIView):
179
178
...
180
179
schema = AutoSchema(
181
- manual_fields= {
182
- "extra_field": coreapi.Field(...)
183
- }
180
+ manual_fields=[
181
+ coreapi.Field( "extra_field", ...),
182
+ ]
184
183
)
185
184
186
185
This allows extension for the most common case without subclassing.
@@ -512,9 +511,22 @@ A class that deals with introspection of individual views for schema generation.
512
511
513
512
` AutoSchema ` is attached to ` APIView ` via the ` schema ` attribute.
514
513
515
- Typically you will subclass ` AutoSchema ` to customise schema generation
516
- and then set your subclass on your view.
514
+ The ` AutoSchema ` constructor takes a single keyword argument ` manual_fields ` .
515
+
516
+ ### ` manual_fields ` : a ` list ` of ` coreapi.Field ` instances that will be added to
517
+ the generated fields. Generated fields with a matching ` name ` will be overwritten.
517
518
519
+ class CustomView(APIView):
520
+ schema = AutoSchema(manual_fields=[
521
+ coreapi.Field(
522
+ "my_extra_field",
523
+ required=True,
524
+ location="path",
525
+ schema=coreschema.String()
526
+ ),
527
+ ])
528
+
529
+ For more advanced customisation subclass ` AutoSchema ` to customise schema generation.
518
530
519
531
class CustomViewSchema(AutoSchema):
520
532
"""
@@ -529,10 +541,13 @@ and then set your subclass on your view.
529
541
class MyView(APIView):
530
542
schema = CustomViewSchema()
531
543
544
+ The following methods are available to override.
545
+
532
546
### get_link(self, path, method, base_url)
533
547
534
548
Returns a ` coreapi.Link ` instance corresponding to the given view.
535
549
550
+ This is the main entry point.
536
551
You can override this if you need to provide custom behaviors for particular views.
537
552
538
553
### get_description(self, path, method)
@@ -565,7 +580,7 @@ Return a list of `coreapi.Link()` instances, as returned by the `get_schema_fiel
565
580
566
581
## ManualSchema
567
582
568
- ` APIViewSchemaDescriptor ` subclass for specifying a manual schema.
583
+ Allows specifying a manual schema for a view:
569
584
570
585
class MyView(APIView):
571
586
schema = ManualSchema(coreapi.Link(
0 commit comments