mirror of
https://github.com/kennethreitz/responder.git
synced 2026-06-05 06:46:14 +00:00
OpenAPI: Make extension optional
Install with: pip install 'responder[openapi]'
This commit is contained in:
committed by
Andreas Motl
parent
aba96525ad
commit
2741c74b90
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user