Skip to content

Swagger Resolution Errors #87

@Goldziher

Description

@Goldziher

Expected Behaviour

Minimal Example Spec

Actual Behaviour

Steps to Reproduce

Environment

  • OS: maxOf
  • Python version: 3.9
  • Swagger/OpenAPI version used: swagger 2.0
  • Backend: (flex, swagger-spec-validator or openapi-spec-validator) using the resolver directly

Hi there, and first off thanks for this resolver!

I'm maintaining another library that relies on Prance as a derferencer. It works well in most cases, but I think I encountered a bug. I'm testing our library (https://github.com/snok/drf-openapi-tester) against various specs, and now I'm trying to test it against the kubernetes swgger 2.0 docs:, which can be found here: https://raw.githubusercontent.com/kubernetes/kubernetes/master/api/openapi-spec/swagger.json

It seems that this spec cannot be resolved at present because instead of a url what is passed to the following function is a dictionary {type: string}:

def absurl(url, relative_to = None):
....
# prance.util.url lines 49-59
  parsed = url
  if not isinstance(parsed, tuple):
    from .fs import is_pathname_valid
    if is_pathname_valid(url):
      from . import fs
      url = fs.to_posix(url)
    try:
      parsed = parse.urlparse(url)
    except Exception as ex:
      from .exceptions import raise_from
      raise_from(ResolutionError, ex, 'Unable to parse url: %s' % (url,))

I got to this point in debugging it.

According to the intellij debugger absurl was called with two parameters:

url={'type': 'string'},
relative_to=ParseResult(scheme='file', netloc='', path='/', params='', query='', fragment='/definitions/io.k8s.apiextensions-apiserver.pkg.apis.apiextensions.v1.JSONSchemaProps')

If you want I can add a json copy of the kubernetes spec to the repo and have it fail in a test if that would help :).

@jfinkhaeuser

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions