| 1 |
from collections import namedtuple |
| 2 |
|
| 3 |
import pytest |
| 4 |
|
| 5 |
from apispec import APISpec |
| 6 |
from apispec.ext.marshmallow import MarshmallowPlugin |
| 7 |
|
| 8 |
|
| 9 |
def make_spec(openapi_version): |
| 10 |
ma_plugin = MarshmallowPlugin() |
| 11 |
spec = APISpec( |
| 12 |
title="Validation", |
| 13 |
version="0.1", |
| 14 |
openapi_version=openapi_version, |
| 15 |
plugins=(ma_plugin,), |
| 16 |
) |
| 17 |
return namedtuple("Spec", ("spec", "marshmallow_plugin", "openapi"))( |
| 18 |
spec, ma_plugin, ma_plugin.converter |
| 19 |
) |
| 20 |
|
| 21 |
|
| 22 |
@pytest.fixture(params=("2.0", "3.0.0")) |
| 23 |
def spec_fixture(request): |
| 24 |
return make_spec(request.param) |
| 25 |
|
| 26 |
|
| 27 |
@pytest.fixture(params=("2.0", "3.0.0")) |
| 28 |
def spec(request): |
| 29 |
return make_spec(request.param).spec |
| 30 |
|
| 31 |
|
| 32 |
@pytest.fixture(params=("2.0", "3.0.0")) |
| 33 |
def openapi(request): |
| 34 |
spec = make_spec(request.param) |
| 35 |
return spec.openapi |