@@ -27,6 +27,13 @@ class CommandArguments(BaseCommand):
27
27
default = '' ,
28
28
help = 'Output file (default: schema.json)'
29
29
),
30
+ make_option (
31
+ '--indent' ,
32
+ type = int ,
33
+ dest = 'indent' ,
34
+ default = None ,
35
+ help = 'Output file indent (default: None)'
36
+ ),
30
37
)
31
38
else :
32
39
class CommandArguments (BaseCommand ):
@@ -46,14 +53,21 @@ def add_arguments(self, parser):
46
53
default = graphene_settings .SCHEMA_OUTPUT ,
47
54
help = 'Output file (default: schema.json)' )
48
55
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
+
49
63
50
64
class Command (CommandArguments ):
51
65
help = 'Dump Graphene schema JSON to file'
52
66
can_import_settings = True
53
67
54
- def save_file (self , out , schema_dict ):
68
+ def save_file (self , out , schema_dict , indent ):
55
69
with open (out , 'w' ) as outfile :
56
- json .dump (schema_dict , outfile )
70
+ json .dump (schema_dict , outfile , indent = indent )
57
71
58
72
def handle (self , * args , ** options ):
59
73
options_schema = options .get ('schema' )
@@ -74,8 +88,9 @@ def handle(self, *args, **options):
74
88
if not schema :
75
89
raise CommandError ('Specify schema on GRAPHENE.SCHEMA setting or by using --schema' )
76
90
91
+ indent = options .get ('indent' )
77
92
schema_dict = {'data' : schema .introspect ()}
78
- self .save_file (out , schema_dict )
93
+ self .save_file (out , schema_dict , indent )
79
94
80
95
style = getattr (self , 'style' , None )
81
96
success = getattr (style , 'SUCCESS' , lambda x : x )
0 commit comments