essentials-openapi icon indicating copy to clipboard operation
essentials-openapi copied to clipboard

Crash during generation

Open foxpluto opened this issue 1 year ago • 1 comments

I found a possible bug,

here is the stack trace:

ERROR   -  Error reading page 'software/hermes/api.md': 'list' object has no attribute 'get'
Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.11/site-packages/mkdocs/livereload/__init__.py", line 190, in _build_loop
    func()
  File "/opt/homebrew/lib/python3.11/site-packages/mkdocs/commands/serve.py", line 67, in builder
    build(config, live_server=None if is_clean else server, dirty=is_dirty)
  File "/opt/homebrew/lib/python3.11/site-packages/mkdocs/commands/build.py", line 322, in build
    _populate_page(file.page, config, files, dirty)
  File "/opt/homebrew/lib/python3.11/site-packages/mkdocs/commands/build.py", line 171, in _populate_page
    page.markdown = config.plugins.on_page_markdown(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/mkdocs/plugins.py", line 575, in on_page_markdown
    return self.run_event('page_markdown', markdown, page=page, config=config, files=files)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/mkdocs/plugins.py", line 507, in run_event
    result = method(item, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/neoteroi/mkdocs/oad/__init__.py", line 44, in on_page_markdown
    return self.rx.sub(self._replacer, markdown)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/neoteroi/mkdocs/oad/__init__.py", line 34, in _replacer
    return handler.write()
           ^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/openapidocs/mk/v3/__init__.py", line 427, in write
    operations=self.get_operations(),
               ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/openapidocs/mk/v3/__init__.py", line 181, in get_operations
    tag = self.get_tag(path_item) or ""
          ^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/openapidocs/mk/v3/__init__.py", line 219, in get_tag
    tags = operation.get("tags")
           ^^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'get'
ERROR   -  [14:15:23] An error happened during the rebuild. The server will appear stuck until build errors are resolved.

I attach here the openapi which generate the crash

hermesApi.yaml.zip

Thanks, S.

foxpluto avatar May 26 '24 12:05 foxpluto

same with me

adelelawady avatar Sep 28 '24 22:09 adelelawady

This is related to the get_tag bug in #34. @RobertoPrevato, I recommend closing this in favor of #34 and I will lightly mention what's going on in that issue.

bitsondatadev avatar Dec 10 '24 21:12 bitsondatadev

Hi @foxpluto @adelelawady @bitsondatadev This has been fixed at 1.1.1, it was caused by improper handling of the Path Item object (it was treated as if it could only contain child properties of type Operation Item). In 1.1.1 I resolved the issue with path items having summary, description, and common parameters like in the example above.

RobertoPrevato avatar Mar 20 '25 20:03 RobertoPrevato