@@ -1543,15 +1543,17 @@ def test_url_with_http_headers(mock_httpx_get: HttpxGetMockFactory, output_file:
15431543
15441544The `--http-local-ref-path` flag maps HTTP(S) `$ref` URLs to files under
15451545a local schema store instead of fetching them from the network. The host and
1546- URL path are used as the relative path under the schema store.""" ,
1547- input_schema = "jsonschema/pet_simple.json" ,
1546+ URL path are used as the relative path under the schema store. For example,
1547+ `https://api.example.com/schemas/pet.json` is read from
1548+ `schemas/api.example.com/schemas/pet.json`.""" ,
1549+ input_schema = "jsonschema/http_local_ref_path_root.json" ,
15481550 cli_args = [
15491551 "--url" ,
15501552 "https://api.example.com/schema.json" ,
15511553 "--http-local-ref-path" ,
15521554 "schemas" ,
15531555 ],
1554- golden_output = "main_kr/url_with_headers /output.py" ,
1556+ golden_output = "main_kr/http_local_ref_path /output.py" ,
15551557)
15561558@freeze_time ("2019-07-26" )
15571559def test_http_local_ref_path_cli_doc (mock_httpx_get : HttpxGetMockFactory , output_file : Path , tmp_path : Path ) -> None :
@@ -1562,17 +1564,22 @@ def test_http_local_ref_path_cli_doc(mock_httpx_get: HttpxGetMockFactory, output
15621564 URL path are used as the relative path under the schema store.
15631565 """
15641566 schema_store = tmp_path / "schemas"
1565- schema_store .mkdir ()
1567+ local_schema = schema_store / "api.example.com" / "schemas" / "pet.json"
1568+ local_schema .parent .mkdir (parents = True )
1569+ local_schema .write_text ((JSON_SCHEMA_DATA_PATH / "pet_simple.json" ).read_text (), encoding = "utf-8" )
15661570 mock_get = mock_httpx_get (
1567- MockHttpxResponse ("https://api.example.com/schema.json" , JSON_SCHEMA_DATA_PATH / "pet_simple.json" )
1571+ MockHttpxResponse (
1572+ "https://api.example.com/schema.json" ,
1573+ JSON_SCHEMA_DATA_PATH / "http_local_ref_path_root.json" ,
1574+ )
15681575 )
15691576
15701577 run_main_url_and_assert (
15711578 url = "https://api.example.com/schema.json" ,
15721579 output_path = output_file ,
15731580 input_file_type = "jsonschema" ,
15741581 assert_func = assert_file_content ,
1575- expected_file = EXPECTED_MAIN_KR_PATH / "url_with_headers " / "output.py" ,
1582+ expected_file = EXPECTED_MAIN_KR_PATH / "http_local_ref_path " / "output.py" ,
15761583 extra_args = ["--http-local-ref-path" , str (schema_store )],
15771584 )
15781585 assert_httpx_get_kwargs (mock_get )
0 commit comments