Skip to content

IndexError when definition titles have less than 3 components #57

Description

@larsks

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions