1616 allow_null_optional_fields ,
1717 change_dict_values ,
1818 append_no_duplicates ,
19+ parse_headers ,
1920)
2021from openapi2jsonschema .errors import UnsupportedError
2122
3435 default = "_definitions.json" ,
3536 help = "Prefix for JSON references (only for OpenAPI versions before 3.0)" ,
3637)
38+ @click .option (
39+ "-H" ,
40+ "--header" ,
41+ multiple = True ,
42+ help = "Extra header to use when getting a schema. May be specified multiple times." ,
43+ )
3744@click .option (
3845 "--stand-alone" , is_flag = True , help = "Whether or not to de-reference JSON schemas"
3946)
4956 help = "Prohibits properties not in the schema (additionalProperties: false)" ,
5057)
5158@click .argument ("schema" , metavar = "SCHEMA_URL" )
52- def default (output , schema , prefix , stand_alone , expanded , kubernetes , strict ):
59+ def default (output , schema , prefix , header , stand_alone , expanded , kubernetes , strict ):
5360 """
5461 Converts a valid OpenAPI specification into a set of JSON Schema files
5562 """
@@ -59,7 +66,11 @@ def default(output, schema, prefix, stand_alone, expanded, kubernetes, strict):
5966 else :
6067 if os .path .isfile (schema ):
6168 schema = "file://" + os .path .realpath (schema )
62- req = urllib .request .Request (schema )
69+ if header :
70+ headers = parse_headers (header )
71+ req = urllib .request .Request (schema , headers = headers )
72+ else :
73+ req = urllib .request .Request (schema )
6374 response = urllib .request .urlopen (req )
6475
6576 info ("Parsing schema" )
0 commit comments