mirror of
https://github.com/kennethreitz/responder.git
synced 2026-06-05 06:46:14 +00:00
OpenAPI: Refactor module to responder.ext.openapi
It has been `responder.ext.schema` before.
This commit is contained in:
committed by
Andreas Motl
parent
2741c74b90
commit
3aa21eed08
@@ -50,7 +50,8 @@ Include support for all extensions and interfaces:
|
||||
|
||||
Individual optional installation extras are:
|
||||
|
||||
graphql, openapi
|
||||
- graphql: Adds GraphQL support via Graphene
|
||||
- openapi: Adds OpenAPI/Swagger interface support
|
||||
|
||||
Or, install directly from the repository:
|
||||
|
||||
|
||||
+12
-7
@@ -66,10 +66,16 @@ Responder comes with built-in support for OpenAPI / marshmallow::
|
||||
|
||||
pip install 'responder[openapi]'
|
||||
|
||||
New in Responder `1.4.0`::
|
||||
.. note::
|
||||
|
||||
If you're upgrading from a previous version, note that the OpenAPI module
|
||||
has been renamed from ``responder.ext.schema`` to ``responder.ext.openapi``.
|
||||
Update your imports accordingly.
|
||||
|
||||
New in Responder 1.4.0::
|
||||
|
||||
import responder
|
||||
from responder.ext.schema import Schema as OpenAPISchema
|
||||
from responder.ext.openapi import OpenAPISchema
|
||||
from marshmallow import Schema, fields
|
||||
|
||||
contact = {
|
||||
@@ -200,12 +206,11 @@ Responder can automatically supply API Documentation for you. Using the example
|
||||
|
||||
The new and recommended way::
|
||||
|
||||
...
|
||||
from responder.ext.schema import Schema
|
||||
...
|
||||
from responder.ext.openapi import OpenAPISchema
|
||||
|
||||
api = responder.API()
|
||||
|
||||
schema = Schema(
|
||||
schema = OpenAPISchema(
|
||||
app=api,
|
||||
title="Web Service",
|
||||
version="1.0",
|
||||
@@ -220,7 +225,7 @@ The new and recommended way::
|
||||
)
|
||||
|
||||
|
||||
The old way ::
|
||||
The old way::
|
||||
|
||||
api = responder.API(
|
||||
title="Web Service",
|
||||
|
||||
+7
-1
@@ -109,7 +109,13 @@ class API:
|
||||
self.add_middleware(SessionMiddleware, secret_key=self.secret_key)
|
||||
|
||||
if openapi or docs_route:
|
||||
from .ext.schema import OpenAPISchema
|
||||
try:
|
||||
from .ext.openapi import OpenAPISchema
|
||||
except ImportError as ex:
|
||||
raise ImportError(
|
||||
"The dependencies for the OpenAPI extension are not installed. "
|
||||
"Install them using: pip install 'responder[openapi]'"
|
||||
) from ex
|
||||
|
||||
self.openapi = OpenAPISchema(
|
||||
app=self,
|
||||
|
||||
@@ -134,7 +134,7 @@ setup(
|
||||
],
|
||||
"full": ["responder[graphql,openapi]"],
|
||||
"graphql": ["graphene"],
|
||||
"openapi": ["apispec>=1.0.0b1"],
|
||||
"openapi": ["apispec>=1.0.0"],
|
||||
"release": ["build", "twine"],
|
||||
"test": ["flask", "mypy", "pytest", "pytest-cov", "pytest-mock"],
|
||||
},
|
||||
|
||||
@@ -326,7 +326,7 @@ def test_schema_generation_explicit(needs_openapi):
|
||||
import marshmallow
|
||||
|
||||
import responder
|
||||
from responder.ext.schema import OpenAPISchema
|
||||
from responder.ext.openapi import OpenAPISchema
|
||||
|
||||
api = responder.API()
|
||||
|
||||
@@ -393,7 +393,7 @@ def test_documentation_explicit(needs_openapi):
|
||||
import marshmallow
|
||||
|
||||
import responder
|
||||
from responder.ext.schema import OpenAPISchema
|
||||
from responder.ext.openapi import OpenAPISchema
|
||||
|
||||
description = "This is a sample server for a pet store."
|
||||
terms_of_service = "http://example.com/terms/"
|
||||
|
||||
Reference in New Issue
Block a user