Describe the bug
Thank you for your work on this tool.
I am working on converting an openapi specification. However, I get an error saying that FileNotFoundError: [Errno 2] No such file or directory: '/Users/cloftus/Documents/schemas/common-core/link.yaml'
. I am confused what this means since there is no reference to that file in my command or openapi file.
I am unsure if it might be related to this: #1579
To Reproduce
I am using the openapi json file at https://sta-edr.internetofwater.dev/openapi?f=json . All data is all contained in that file, but has remote references to other schemas defined via a community standard (i.e. "$ref":"https://schemas.opengis.net/ogcapi/features/part1/1.0/openapi/ogcapi-features-1.yaml#/components/responses/LandingPage"
Commandline reproduction:
pipx install datamodel-code-generator[http]
datamodel-codegen --input openapi --output model.py
Expected behavior
I expected a model.py to be generated from my locally downloaded openapi json specification
Version:
cloftus@host ~> datamodel-codegen --version
0.25.9
Additional context
My openapi specification file is coming from a valid server endpoint. It has lots of $ref values in it. I don't see anything that should be causing an issue however.
Full shell output: (tried as well with manually specifying the input type as --input openapi
cloftus@Coltons-MacBook-Pro ~/Documents [1]> datamodel-codegen --input openapi --input-file-type openapi --output model.py
/Users/cloftus/.local/pipx/venvs/datamodel-code-generator/lib/python3.12/site-packages/datamodel_code_generator/parser/jsonschema.py:338: UserWarning: format of 'url' not understood for 'string' - using default
warn(f'format of {format__!r} not understood for {type_!r} - using default' '')
Traceback (most recent call last):
File "/Users/cloftus/.local/pipx/venvs/datamodel-code-generator/lib/python3.12/site-packages/datamodel_code_generator/__main__.py", line 445, in main
generate(
File "/Users/cloftus/.local/pipx/venvs/datamodel-code-generator/lib/python3.12/site-packages/datamodel_code_generator/__init__.py", line 473, in generate
results = parser.parse()
^^^^^^^^^^^^^^
File "/Users/cloftus/.local/pipx/venvs/datamodel-code-generator/lib/python3.12/site-packages/datamodel_code_generator/parser/base.py", line 1267, in parse
self.parse_raw()
File "/Users/cloftus/.local/pipx/venvs/datamodel-code-generator/lib/python3.12/site-packages/datamodel_code_generator/parser/openapi.py", line 592, in parse_raw
self.parse_raw_obj(
File "/Users/cloftus/.local/pipx/venvs/datamodel-code-generator/lib/python3.12/site-packages/datamodel_code_generator/parser/jsonschema.py", line 1651, in parse_raw_obj
self.parse_obj(name, self.SCHEMA_OBJECT_TYPE.parse_obj(raw), path)
File "/Users/cloftus/.local/pipx/venvs/datamodel-code-generator/lib/python3.12/site-packages/datamodel_code_generator/parser/jsonschema.py", line 1677, in parse_obj
self.parse_ref(obj, path)
File "/Users/cloftus/.local/pipx/venvs/datamodel-code-generator/lib/python3.12/site-packages/datamodel_code_generator/parser/jsonschema.py", line 1611, in parse_ref
self.parse_ref(property_value, path)
File "/Users/cloftus/.local/pipx/venvs/datamodel-code-generator/lib/python3.12/site-packages/datamodel_code_generator/parser/jsonschema.py", line 1592, in parse_ref
self.parse_ref(obj.items, path)
File "/Users/cloftus/.local/pipx/venvs/datamodel-code-generator/lib/python3.12/site-packages/datamodel_code_generator/parser/jsonschema.py", line 1589, in parse_ref
self.resolve_ref(obj.ref)
File "/Users/cloftus/.local/pipx/venvs/datamodel-code-generator/lib/python3.12/site-packages/datamodel_code_generator/parser/jsonschema.py", line 1578, in resolve_ref
self._parse_file(
File "/Users/cloftus/.local/pipx/venvs/datamodel-code-generator/lib/python3.12/site-packages/datamodel_code_generator/parser/jsonschema.py", line 1798, in _parse_file
self.parse_obj(
File "/Users/cloftus/.local/pipx/venvs/datamodel-code-generator/lib/python3.12/site-packages/datamodel_code_generator/parser/jsonschema.py", line 1677, in parse_obj
self.parse_ref(obj, path)
File "/Users/cloftus/.local/pipx/venvs/datamodel-code-generator/lib/python3.12/site-packages/datamodel_code_generator/parser/jsonschema.py", line 1589, in parse_ref
self.resolve_ref(obj.ref)
File "/Users/cloftus/.local/pipx/venvs/datamodel-code-generator/lib/python3.12/site-packages/datamodel_code_generator/parser/jsonschema.py", line 1579, in resolve_ref
self._get_ref_body(relative_path),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/cloftus/.local/pipx/venvs/datamodel-code-generator/lib/python3.12/site-packages/datamodel_code_generator/parser/jsonschema.py", line 1531, in _get_ref_body
return self._get_ref_body_from_remote(resolved_ref)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/cloftus/.local/pipx/venvs/datamodel-code-generator/lib/python3.12/site-packages/datamodel_code_generator/parser/jsonschema.py", line 1544, in _get_ref_body_from_remote
return self.remote_object_cache.get_or_put(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/cloftus/.local/pipx/venvs/datamodel-code-generator/lib/python3.12/site-packages/datamodel_code_generator/parser/__init__.py", line 28, in get_or_put
value = self[key] = default_factory(key)
^^^^^^^^^^^^^^^^^^^^
File "/Users/cloftus/.local/pipx/venvs/datamodel-code-generator/lib/python3.12/site-packages/datamodel_code_generator/parser/jsonschema.py", line 1546, in <lambda>
default_factory=lambda _: load_yaml_from_path(full_path, self.encoding),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/cloftus/.local/pipx/venvs/datamodel-code-generator/lib/python3.12/site-packages/datamodel_code_generator/__init__.py", line 56, in load_yaml_from_path
with path.open(encoding=encoding) as f:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.12.5/Frameworks/Python.framework/Versions/3.12/lib/python3.12/pathlib.py", line 1013, in open
return io.open(self, mode, buffering, encoding, errors, newline)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/Users/cloftus/Documents/schemas/common-core/link.yaml'
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too