ergo / pyramid_apispec

Pyramid plugin for openapi spec generation (using ApiSpec)
BSD 3-Clause "New" or "Revised" License
23 stars 10 forks source link

Unable to generate API specification using marshmallow schema containing field having type as list/array of String eg. myfield = [“str1”,”str2”]. My Marshmallow version=3.6.1 #15

Closed saurabhjakhade closed 3 years ago

saurabhjakhade commented 4 years ago

I am unable to create / generate API specification using marshmallow schema containing field having type as list/array of String.

Details : My local version details -

"pyramid_apispec==0.3.3", "marshmallow==3.6.1 , pyramid==1.10.4 , python == 3.7.3"

My code looks like :

import marshmallow from marshmallow import fields, validate

class BaseSchema(marshmallow.Schema): class Meta: strict = True ordered = True

class MyCustomSchema(BaseSchema) : app_ids = fields.List(fields.String())

Here when I tried to access api specification http://localhost:8080/api-explorer . I got following error –

File "d:\saurabh\june-venv\lib\site-packages\apispec\core.py", line 143, in schema ret.update(plugin.schema_helper(name, component, kwargs) or {}) File "d:\saurabh\june-venv\lib\site-packages\apispec\ext\marshmallow__init__.py", line 169, in schema_helper json_schema = self.openapi.schema2jsonschema(schema_instance) File "d:\saurabh\june-venv\lib\site-packages\apispec\ext\marshmallow\openapi.py", line 657, in schema2jsonschema jsonschema = self.fields2jsonschema(fields, partial=partial, ordered=ordered) File "d:\saurabh\june-venv\lib\site-packages\apispec\ext\marshmallow\openapi.py", line 681, in fields2jsonschema property = self.field2property(field_obj) File "d:\saurabh\june-venv\lib\site-packages\apispec\ext\marshmallow\openapi.py", line 433, in field2property ret["items"] = self.field2property(field.container) AttributeError: 'List' object has no attribute 'container'**

ergo commented 4 years ago

Hi, can you prepare me a repo with minimal test case?

ergo commented 4 years ago

I've pushed changes to the package bumping apispec itself, can you install trunk version and check if this resolves your issue?

Lauriy commented 4 years ago

Helped me.

smsearcy commented 3 years ago

Installing the master branch of pyramid_apispec resolved the error AttributeError: 'List' object has no attribute 'container' for me as well (and that upgrade bumped apispec to 4.0.0).

Is there a timeframe or other needs for pushing a new release to PyPI?

Edit: Working with this a little more I found that the current example in the README doesn't work with apispec>=2.0.0, I'm going to open an issue (and hopefully PR) for that. In case that affects your plans for releasing to PyPI.

ergo commented 3 years ago

Hi, I'm sorry this completely fell off my mind. I've made a new release of the package.