OpenAPI: Make extension optional

Install with: pip install 'responder[openapi]'
This commit is contained in:
Andreas Motl
2024-10-26 04:42:57 +02:00
committed by Andreas Motl
parent aba96525ad
commit 2741c74b90
7 changed files with 64 additions and 14 deletions
+10
View File
@@ -53,3 +53,13 @@ def template_path(tmpdir):
template_file = tmpdir.mkdir("static").join(template_name)
template_file.write("{{ var }}")
return template_file
@pytest.fixture
def needs_openapi() -> None:
try:
import apispec
_ = apispec.APISpec
except ImportError as ex:
raise pytest.skip("apispec package not installed") from ex
+6 -6
View File
@@ -322,11 +322,11 @@ def test_yaml_downloads(api):
assert yaml.safe_load(r.content) == dump
def test_schema_generation_explicit():
def test_schema_generation_explicit(needs_openapi):
import marshmallow
import responder
from responder.ext.schema import OpenAPISchema as OpenAPISchema
from responder.ext.schema import OpenAPISchema
api = responder.API()
@@ -357,7 +357,7 @@ def test_schema_generation_explicit():
assert dump["openapi"] == "3.0.2"
def test_schema_generation():
def test_schema_generation(needs_openapi):
from marshmallow import Schema, fields
import responder
@@ -389,11 +389,11 @@ def test_schema_generation():
assert dump["openapi"] == "3.0.2"
def test_documentation_explicit():
def test_documentation_explicit(needs_openapi):
import marshmallow
import responder
from responder.ext.schema import OpenAPISchema as OpenAPISchema
from responder.ext.schema import OpenAPISchema
description = "This is a sample server for a pet store."
terms_of_service = "http://example.com/terms/"
@@ -443,7 +443,7 @@ def test_documentation_explicit():
assert "html" in r.text
def test_documentation():
def test_documentation(needs_openapi):
from marshmallow import Schema, fields
import responder