@@ -271,27 +271,14 @@ class SchemaGenerator(drf_openapi.SchemaGenerator):
271
271
Extend DRF's SchemaGenerator to implement jsonapi-flavored generateschema command
272
272
"""
273
273
def __init__ (self , * args , ** kwargs ):
274
- self .openapi_schema = {}
275
274
super ().__init__ (* args , ** kwargs )
276
275
277
276
def get_schema (self , request = None , public = False ):
278
277
"""
279
278
Generate a JSONAPI OpenAPI schema.
280
279
"""
281
- self ._initialise_endpoints ()
282
-
283
- paths = self .get_paths (None if public else request )
284
- if not paths :
285
- return None
286
-
287
- schema = {
288
- 'openapi' : '3.0.2' ,
289
- 'info' : self .get_info (),
290
- 'paths' : paths ,
291
- 'components' : JSONAPI_COMPONENTS ,
292
- }
293
-
294
- return {** schema , ** self .openapi_schema }
280
+ schema = super ().get_schema (request , public )
281
+ return {** schema , 'components' : JSONAPI_COMPONENTS }
295
282
296
283
def get_paths (self , request = None ):
297
284
"""
@@ -346,9 +333,6 @@ def get_paths(self, request=None):
346
333
347
334
result .setdefault (path , {})
348
335
result [path ][method .lower ()] = operation
349
- if hasattr (view .schema , 'openapi_schema' ):
350
- # TODO: shallow or deep merge?
351
- self .openapi_schema = {** self .openapi_schema , ** view .schema .openapi_schema }
352
336
353
337
return result
354
338
@@ -439,21 +423,11 @@ class AutoSchema(drf_openapi.AutoSchema):
439
423
"""
440
424
content_types = ['application/vnd.api+json' ]
441
425
442
- def __init__ (self , openapi_schema = {} ):
426
+ def __init__ (self ):
443
427
"""
444
428
Initialize the JSONAPI OAS schema generator
445
- :param openapi_schema: dict: OAS 3.0 document with initial values.
446
429
"""
447
430
super ().__init__ ()
448
- #: allow initialization of OAS schema doc
449
- self .openapi_schema = openapi_schema
450
- # static JSONAPI fields that get $ref'd to in the view mappings
451
- jsonapi_ref = {
452
- 'components' : JSONAPI_COMPONENTS
453
- }
454
- # merge in our reference data on top of anything provided by the init.
455
- # TODO: shallow or deep merge?
456
- self .openapi_schema = {** self .openapi_schema , ** jsonapi_ref }
457
431
458
432
def get_operation (self , path , method , action = None ):
459
433
""" basically a copy of AutoSchema.get_operation """
0 commit comments