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

[OpenAPI Docs, Question] Support for multi-file specifications #50

Open
aremes opened this issue Dec 6, 2023 · 0 comments
Open

[OpenAPI Docs, Question] Support for multi-file specifications #50

aremes opened this issue Dec 6, 2023 · 0 comments

Comments

@aremes
Copy link

aremes commented Dec 6, 2023

Hi!
My OpenAPI spec gets properly translated into markdown and looks superb in mkdocs. However, since the file is pretty large it's a user-experience nightmare to have it all in one page. I was hoping to split the file (using redoclys openapi split command). This generates a root openapi.yaml file. Including this in an index.md using [OAD(<path-to-openapi.yaml>)] throws the following error:

Error reading page 'index.md': maximum recursion depth exceeded while calling a Python object

Here's the top of the stack trace (the last three lines then keep repeating for a while)

Traceback (most recent call last):
  File "C:\Users\idontthinkso\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\idontthinkso\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\idontthinkso\AppData\Local\Programs\Python\Python310\Scripts\mkdocs.exe\__main__.py", line 7, in <module>
  File "C:\Users\idontthinkso\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\idontthinkso\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "C:\Users\idontthinkso\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\idontthinkso\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\idontthinkso\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\idontthinkso\AppData\Local\Programs\Python\Python310\lib\site-packages\mkdocs\__main__.py", line 286, in build_command
    build.build(cfg, dirty=not clean)
  File "C:\Users\idontthinkso\AppData\Local\Programs\Python\Python310\lib\site-packages\mkdocs\commands\build.py", line 322, in build
    _populate_page(file.page, config, files, dirty)
  File "C:\Users\idontthinkso\AppData\Local\Programs\Python\Python310\lib\site-packages\mkdocs\commands\build.py", line 171, in _populate_page
    page.markdown = config.plugins.on_page_markdown(
  File "C:\Users\idontthinkso\AppData\Local\Programs\Python\Python310\lib\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 "C:\Users\idontthinkso\AppData\Local\Programs\Python\Python310\lib\site-packages\mkdocs\plugins.py", line 507, in run_event
    result = method(item, **kwargs)
  File "C:\Users\idontthinkso\AppData\Local\Programs\Python\Python310\lib\site-packages\neoteroi\mkdocs\oad\__init__.py", line 44, in on_page_markdown
    return self.rx.sub(self._replacer, markdown)
  File "C:\Users\idontthinkso\AppData\Local\Programs\Python\Python310\lib\site-packages\neoteroi\mkdocs\oad\__init__.py", line 31, in _replacer
    handler = OpenAPIV3DocumentationHandler(
  File "C:\Users\idontthinkso\AppData\Local\Programs\Python\Python310\lib\site-packages\openapidocs\mk\v3\__init__.py", line 104, in __init__
    self.doc = self.normalize_data(copy.deepcopy(doc))
  File "C:\Users\idontthinkso\AppData\Local\Programs\Python\Python310\lib\site-packages\openapidocs\mk\v3\__init__.py", line 127, in normalize_data
    return self._transform_data(
  File "C:\Users\idontthinkso\AppData\Local\Programs\Python\Python310\lib\site-packages\openapidocs\mk\v3\__init__.py", line 144, in _transform_data
    clone[key] = self._handle_obj_ref(value, source_path)
  File "C:\Users\idontthinkso\AppData\Local\Programs\Python\Python310\lib\site-packages\openapidocs\mk\v3\__init__.py", line 170, in _handle_obj_ref
    return self._transform_data(obj, source_path)
  File "C:\Users\idontthinkso\AppData\Local\Programs\Python\Python310\lib\site-packages\openapidocs\mk\v3\__init__.py", line 144, in _transform_data
    clone[key] = self._handle_obj_ref(value, source_path)
  File "C:\Users\idontthinkso\AppData\Local\Programs\Python\Python310\lib\site-packages\openapidocs\mk\v3\__init__.py", line 167, in _handle_obj_ref
    return self._transform_data(sub_fragment, referred_file.parent)

So:

  1. Should there even be support for this?
  2. If not, would you be interested in adding it (i may consider contributing, but my python is rusty so dont hold your breath :)
  3. If supported: What am I dong wrong?
  4. Also if supported: Would that generate .md files for each part or still put it all in a single file?

I wouldnt mind skipping the redocly part altogether if there was an option to instruct your plugin to output the result from a single spec into multiple .md files (i.e. by tag, path, etc .. similarly to what openapi split does.)
I havent yet looked into the source and before i do that, i just would like to ask:

  • would that be very difficult to do?
  • would you be willing to consider a PR that adds such a feature?

Best Regards!

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