marshmallow-code / apispec

A pluggable API specification generator. Currently supports the OpenAPI Specification (f.k.a. the Swagger specification)..

Home Page:https://apispec.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Marshmallow OpenApiConverter does not support str openapi_version

paradoxxxzero opened this issue · comments

The mashmallow ext documentation says

openapi_version (Version) – The OpenAPI version to use. Should be in the form ‘2.x’ or ‘3.x.x’ to comply with the OpenAPI standard.

but in APISpec str is supported which leads to confusion:

openapi_version (str) – OpenAPI Specification version. Should be in the form ‘2.x’ or ‘3.x.x’ to comply with the OpenAPI standard.

This commit has removed the conversion from str to version instance in marshmallow ext:
d9e7ef9#diff-d2965e63925ff25611aef4a29719e18095c4a035c9a855e65d4d8ea7908298b8L54-L60

which when using str version leads to errors like AttributeError: 'str' object has no attribute 'major' here https://github.com/marshmallow-code/apispec/blob/dev/src/apispec/ext/marshmallow/openapi.py#L191 in version 6.0.1

Is it the desired behavior?
Thanks

Right. Sorry about that. Would you like to send a fix (cast to Version)?

Why not :)

Here you go #811

Fix released in 6.0.2!