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

IndexError when definition titles have less than 3 components #57

Open
larsks opened this issue Nov 5, 2021 · 0 comments · May be fixed by #58
Open

IndexError when definition titles have less than 3 components #57

larsks opened this issue Nov 5, 2021 · 0 comments · May be fixed by #58

Comments

@larsks
Copy link

larsks commented Nov 5, 2021

Faced with a definition like this:

  "v1.APIGroup": {
    "description": "APIGroup contains the name, the supported versions, and the preferred version of a group.",
    "type": "object",
    "required": [
      "name",
      "versions"
    ],
   ...

openapi2jsonschema will fail with:

Traceback (most recent call last):
  File "/home/lars/.local/bin/openapi2jsonschema", line 8, in <module>
    sys.exit(default())
  File "/home/lars/.local/lib/python3.10/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/lars/.local/lib/python3.10/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/lars/.local/lib/python3.10/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/lars/.local/lib/python3.10/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/lars/.local/lib/python3.10/site-packages/openapi2jsonschema/command.py", line 136, in default
    group = title.split(".")[-3].lower()
IndexError: list index out of range
larsks added a commit to larsks/openapi2jsonschema that referenced this issue Nov 5, 2021
This will cause `openapi2jsonschema to skip definitions that have
fewer than 3 components in the name (like `v1.APIGroup`), rather than
crashing with an IndexError.

Closes instrumenta#57
larsks added a commit to larsks/openapi2jsonschema that referenced this issue Mar 30, 2023
This will cause `openapi2jsonschema to skip definitions that have
fewer than 3 components in the name (like `v1.APIGroup`), rather than
crashing with an IndexError.

Closes instrumenta#57
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

Successfully merging a pull request may close this issue.

1 participant