@@ -27,6 +27,13 @@ class CommandArguments(BaseCommand):
2727 default = '' ,
2828 help = 'Output file (default: schema.json)'
2929 ),
30+ make_option (
31+ '--indent' ,
32+ type = int ,
33+ dest = 'indent' ,
34+ default = None ,
35+ help = 'Output file indent (default: None)'
36+ ),
3037 )
3138else :
3239 class CommandArguments (BaseCommand ):
@@ -46,14 +53,21 @@ def add_arguments(self, parser):
4653 default = graphene_settings .SCHEMA_OUTPUT ,
4754 help = 'Output file (default: schema.json)' )
4855
56+ parser .add_argument (
57+ '--indent' ,
58+ type = int ,
59+ dest = 'indent' ,
60+ default = graphene_settings .SCHEMA_INDENT ,
61+ help = 'Output file indent (default: None)' )
62+
4963
5064class Command (CommandArguments ):
5165 help = 'Dump Graphene schema JSON to file'
5266 can_import_settings = True
5367
54- def save_file (self , out , schema_dict ):
68+ def save_file (self , out , schema_dict , indent ):
5569 with open (out , 'w' ) as outfile :
56- json .dump (schema_dict , outfile )
70+ json .dump (schema_dict , outfile , indent = indent )
5771
5872 def handle (self , * args , ** options ):
5973 options_schema = options .get ('schema' )
@@ -74,8 +88,9 @@ def handle(self, *args, **options):
7488 if not schema :
7589 raise CommandError ('Specify schema on GRAPHENE.SCHEMA setting or by using --schema' )
7690
91+ indent = options .get ('indent' )
7792 schema_dict = {'data' : schema .introspect ()}
78- self .save_file (out , schema_dict )
93+ self .save_file (out , schema_dict , indent )
7994
8095 style = getattr (self , 'style' , None )
8196 success = getattr (style , 'SUCCESS' , lambda x : x )
0 commit comments