Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileNotFoundError for schemas/common-core/link.yaml #2080

Open
C-Loftus opened this issue Aug 31, 2024 · 0 comments
Open

FileNotFoundError for schemas/common-core/link.yaml #2080

C-Loftus opened this issue Aug 31, 2024 · 0 comments

Comments

@C-Loftus
Copy link

C-Loftus commented Aug 31, 2024

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:

  • OS: MacOS Sonoma 14.3
  • Python version: python 3.12 with pipx 1.7.1
  • datamodel-code-generator 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'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant