openapi2jsonschema icon indicating copy to clipboard operation
openapi2jsonschema copied to clipboard

IndexError when definition titles have less than 3 components

Open larsks opened this issue 4 years ago • 0 comments

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 avatar Nov 05 '21 19:11 larsks