question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

__init__() missing 2 required positional arguments: 'schema_name_resolver' and 'spec'

See original GitHub issue

Hello, I’m getting the error below. Am I missing anything?

../../../env36/lib64/python3.6/site-packages/flask_base/app.py:1: in <module>
    from flasgger import Swagger, LazyString, LazyJSONEncoder
../../../env36/lib64/python3.6/site-packages/flasgger/__init__.py:8: in <module>
    from .base import Swagger, Flasgger, NO_SANITIZER, BR_SANITIZER, MK_SANITIZER, LazyJSONEncoder  # noqa
../../../env36/lib64/python3.6/site-packages/flasgger/base.py:37: in <module>
    from .utils import extract_definitions
../../../env36/lib64/python3.6/site-packages/flasgger/utils.py:22: in <module>
    from .marshmallow_apispec import SwaggerView
../../../env36/lib64/python3.6/site-packages/flasgger/marshmallow_apispec.py:13: in <module>
    openapi_converter = openapi.OpenAPIConverter(openapi_version='2.0')
E   TypeError: __init__() missing 2 required positional arguments: 'schema_name_resolver' and 'spec'

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:23
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
dhughesni-zzcommented, Feb 17, 2019

I have identified the same error, although I was unable to trace the exact change in either module: apispec or marshmallow.

Investigation

The error reports in flasgger:

../../../env36/lib64/python3.6/site-packages/flasgger/marshmallow_apispec.py:13: in <module>
    openapi_converter = openapi.OpenAPIConverter(openapi_version='2.0')
E   TypeError: __init__() missing 2 required positional arguments: 'schema_name_resolver' and 'spec'

The file was last changed 8 months ago with 54d9e77 on 29 Jun 2018: https://github.com/rochacbruno/flasgger/blob/master/flasgger/marshmallow_apispec.py

The file imports the following: from apispec.ext.marshmallow import openapi

Which leads us to: https://github.com/marshmallow-code/apispec/blob/dev/apispec/ext/marshmallow/openapi.py#L107 After reviewing the commits, it seems the following changes may have resulted in the error in flasgger:

The fix to flasgger

https://github.com/rochacbruno/flasgger/blob/master/flasgger/marshmallow_apispec.py#L13

openapi_converter = openapi.OpenAPIConverter(
    openapi_version="2.0", 
    schema_name_resolver=None, 
    spec=None
)

This change enables the code to run, but I am not aware of any underlying implications or restrictions of specifying None.

Note: apisepc contains a default resolver method, again I am not aware of whether flasgger should default to this. https://github.com/marshmallow-code/apispec/blob/dev/apispec/ext/marshmallow/__init__.py#L40

I hope this investigation helps in the resolution of the issue.

4reactions
kushan-gunasekeracommented, Jul 25, 2019

This issue is fixed now, but still not in pypi. Try to install it using pip install https://github.com/rochacbruno/flasgger/tarball/master.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: __init__() missing 2 required positional arguments
The Python TypeError: init () missing 2 required positional arguments occurs when we forget to provide 2 required arguments when instantiating a class....
Read more >
Developers - __init__() missing 2 required positional arguments
__init__() missing 2 required positional arguments: 'schema_name_resolver' and 'spec' ... Hello, I'm getting the error below. Am I missing ...
Read more >
TypeError: __init__() missing 2 required positional arguments
I'm trying to return some values from a function in a class but it's giving me this error. TypeError: __init__() missing 2 required...
Read more >
TypeError: __init__() missing 1 required positional argument
here is my code: import torch import torchaudio import matplotlib.pyplot as plt import os import torch.nn as nn import soundfile as sf from ......
Read more >
Built-in Plugins — apispec 6.0.2 documentation
APISpec plugin for translating marshmallow schemas to OpenAPI/JSONSchema format. Parameters. schema_name_resolver (callable) –.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found