Skip to content

Commit bb34131

Browse files
committed
Rename to flask-apispec.
1 parent 43d7800 commit bb34131

13 files changed

+60
-60
lines changed

README.rst

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
===========
2-
flask-smore
2+
flask-apispec
33
===========
44

5-
.. image:: https://img.shields.io/travis/jmcarp/flask-smore/master.svg
6-
:target: https://travis-ci.org/jmcarp/flask-smore
5+
.. image:: https://img.shields.io/travis/jmcarp/flask-apispec/master.svg
6+
:target: https://travis-ci.org/jmcarp/flask-apispec
77
:alt: Travis-CI
88

9-
.. image:: https://img.shields.io/codecov/c/github/jmcarp/flask-smore/master.svg
10-
:target: https://codecov.io/github/jmcarp/flask-smore
9+
.. image:: https://img.shields.io/codecov/c/github/jmcarp/flask-apispec/master.svg
10+
:target: https://codecov.io/github/jmcarp/flask-apispec
1111
:alt: Code coverage
1212

13-
**flask-smore** is a lightweight tool for building REST APIs in Flask. **flask-smore** uses webargs_ for request parsing, marshmallow_ for response formatting, and apispec_ to automatically generate Swagger markup. You can use **flask-smore** with vanilla Flask or a fuller-featured framework like Flask-RESTful_.
13+
**flask-apispec** is a lightweight tool for building REST APIs in Flask. **flask-apispec** uses webargs_ for request parsing, marshmallow_ for response formatting, and apispec_ to automatically generate Swagger markup. You can use **flask-apispec** with vanilla Flask or a fuller-featured framework like Flask-RESTful_.
1414

1515
Install
1616
-------
1717

1818
.. code-block::
1919
20-
pip install flask-smore
20+
pip install flask-apispec
2121
2222
Quickstart
2323
----------
2424

2525
.. code-block:: python
2626
2727
from flask import Flask
28-
from flask_smore import use_kwargs, marshal_with
28+
from flask_apispec import use_kwargs, marshal_with
2929
3030
from marshmallow import fields, Schema
3131
@@ -43,12 +43,12 @@ Quickstart
4343
def get_pets(**kwargs):
4444
return Pet.query.filter_by(**kwargs)
4545
46-
**flask-smore** works with function- and class-based views:
46+
**flask-apispec** works with function- and class-based views:
4747

4848
.. code-block:: python
4949
5050
from flask import make_response
51-
from flask_smore.views import MethodResource
51+
from flask_apispec.views import MethodResource
5252
5353
class PetResource(MethodResource):
5454
@@ -74,12 +74,12 @@ Quickstart
7474
pet.delete()
7575
return make_response('', 204)
7676
77-
**flask-smore** generates Swagger markup for your view functions and classes:
77+
**flask-apispec** generates Swagger markup for your view functions and classes:
7878

7979
.. code-block:: python
8080
8181
from apispec import APISpec
82-
from flask_smore.apidoc import Documentation
82+
from flask_apispec.apidoc import Documentation
8383
8484
spec = APISpec(
8585
title='pets',
@@ -96,9 +96,9 @@ Quickstart
9696
Notes
9797
-----
9898

99-
**flask-smore** isn't stable yet, and the interface and internals may change. Bug reports and pull requests are much appreciated.
99+
**flask-apispec** isn't stable yet, and the interface and internals may change. Bug reports and pull requests are much appreciated.
100100

101-
**flask-smore** is strongly inspired by Flask-RESTful_ and Flask-RESTplus_, but attempts to provide similar functionality with greater flexibility and less code.
101+
**flask-apispec** is strongly inspired by Flask-RESTful_ and Flask-RESTplus_, but attempts to provide similar functionality with greater flexibility and less code.
102102

103103
.. _webargs: https://webargs.readthedocs.org/
104104
.. _marshmallow: https://marshmallow.readthedocs.org/

examples/petstore.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import six
44
import marshmallow as ma
55

6-
from flask_smore.utils import Ref
7-
from flask_smore import ResourceMeta, doc, marshal_with, use_kwargs
6+
from flask_apispec.utils import Ref
7+
from flask_apispec import ResourceMeta, doc, marshal_with, use_kwargs
88

99
class Pet:
1010
def __init__(self, name, type):
@@ -62,13 +62,13 @@ class PetResource(CrudResource):
6262
import flask.views
6363
from apispec import APISpec
6464

65-
from flask_smore.apidoc import Documentation
65+
from flask_apispec.apidoc import Documentation
6666

6767
app = flask.Flask(__name__)
6868
spec = APISpec(
6969
title='title',
7070
version='v1',
71-
plugins=['smore.ext.marshmallow'],
71+
plugins=['apispec.ext.marshmallow'],
7272
)
7373
docs = Documentation(app, spec)
7474

flask_smore/__init__.py renamed to flask_apispec/__init__.py

+14-14
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import werkzeug
1414
from webargs import flaskparser
1515

16-
from flask_smore import utils
16+
from flask_apispec import utils
1717

1818
def identity(value):
1919
return value
@@ -42,7 +42,7 @@ def __call__(self, *args, **kwargs):
4242

4343
def call_view(self, *args, **kwargs):
4444
config = flask.current_app.config
45-
parser = config.get('SMORE_WEBARGS_PARSER', flaskparser.parser)
45+
parser = config.get('APISPEC_WEBARGS_PARSER', flaskparser.parser)
4646
annotation = utils.resolve_annotations(self.func, 'args', self.instance)
4747
if annotation.apply is not False:
4848
for option in annotation.options:
@@ -53,7 +53,7 @@ def call_view(self, *args, **kwargs):
5353

5454
def marshal_result(self, unpacked, status_code):
5555
config = flask.current_app.config
56-
format_response = config.get('SMORE_FORMAT_RESPONSE', flask.jsonify) or identity
56+
format_response = config.get('APISPEC_FORMAT_RESPONSE', flask.jsonify) or identity
5757
annotation = utils.resolve_annotations(self.func, 'schemas', self.instance)
5858
schemas = utils.merge_recursive(annotation.options)
5959
schema = schemas.get(status_code, schemas.get('default'))
@@ -65,18 +65,18 @@ def marshal_result(self, unpacked, status_code):
6565
return format_output((format_response(output), ) + unpacked[1:])
6666

6767
def activate(func):
68-
if isinstance(func, type) or getattr(func, '__smore__', {}).get('wrapped'):
68+
if isinstance(func, type) or getattr(func, '__apispec__', {}).get('wrapped'):
6969
return func
7070

7171
@functools.wraps(func)
7272
def wrapped(*args, **kwargs):
73-
instance = args[0] if func.__smore__.get('ismethod') else None
73+
instance = args[0] if func.__apispec__.get('ismethod') else None
7474
annotation = utils.resolve_annotations(func, 'wrapper', instance)
7575
wrapper_cls = utils.merge_recursive(annotation.options).get('wrapper', Wrapper)
7676
wrapper = wrapper_cls(func, instance)
7777
return wrapper(*args, **kwargs)
7878

79-
wrapped.__smore__['wrapped'] = True
79+
wrapped.__apispec__['wrapped'] = True
8080
return wrapped
8181

8282
def format_output(values):
@@ -176,17 +176,17 @@ def wrapper(func):
176176

177177
def annotate(func, key, options, **kwargs):
178178
annotation = utils.Annotation(options, **kwargs)
179-
func.__smore__ = func.__dict__.get('__smore__', {})
180-
func.__smore__.setdefault(key, []).insert(0, annotation)
179+
func.__apispec__ = func.__dict__.get('__apispec__', {})
180+
func.__apispec__.setdefault(key, []).insert(0, annotation)
181181

182182
def inherit(child, parents):
183-
child.__smore__ = child.__dict__.get('__smore__', {})
183+
child.__apispec__ = child.__dict__.get('__apispec__', {})
184184
for key in ['args', 'schemas', 'docs']:
185-
child.__smore__.setdefault(key, []).extend(
185+
child.__apispec__.setdefault(key, []).extend(
186186
annotation
187187
for parent in parents
188-
for annotation in getattr(parent, '__smore__', {}).get(key, [])
189-
if annotation not in child.__smore__[key]
188+
for annotation in getattr(parent, '__apispec__', {}).get(key, [])
189+
if annotation not in child.__apispec__[key]
190190
)
191191

192192
class ResourceMeta(type):
@@ -208,6 +208,6 @@ def __new__(mcs, name, bases, attrs):
208208
inherit(value, parents)
209209
setattr(klass, key, activate(value))
210210
if not isinstance(value, staticmethod):
211-
value.__dict__.setdefault('__smore__', {})
212-
value.__smore__['ismethod'] = True
211+
value.__dict__.setdefault('__apispec__', {})
212+
value.__apispec__['ismethod'] = True
213213
return klass

flask_smore/apidoc.py renamed to flask_apispec/apidoc.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
from marshmallow import Schema
1111
from marshmallow.utils import is_instance_or_subclass
1212

13-
from flask_smore import ResourceMeta
14-
from flask_smore.paths import rule_to_path, rule_to_params
15-
from flask_smore.utils import resolve_instance, resolve_annotations, merge_recursive
13+
from flask_apispec import ResourceMeta
14+
from flask_apispec.paths import rule_to_path, rule_to_params
15+
from flask_apispec.utils import resolve_instance, resolve_annotations, merge_recursive
1616

1717
class Documentation(object):
1818
"""API documentation collector.
File renamed without changes.

flask_smore/utils.py renamed to flask_apispec/utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ def merge(self, other):
6767

6868
def resolve_annotations(func, key, parent=None):
6969
annotations = (
70-
getattr(func, '__smore__', {}).get(key, []) +
71-
getattr(parent, '__smore__', {}).get(key, [])
70+
getattr(func, '__apispec__', {}).get(key, []) +
71+
getattr(parent, '__apispec__', {}).get(key, [])
7272
)
7373
return functools.reduce(
7474
lambda first, second: first.merge(second),

flask_smore/views.py renamed to flask_apispec/views.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
import six
44
import flask.views
55

6-
from flask_smore import ResourceMeta
6+
from flask_apispec import ResourceMeta
77

88
class MethodResourceMeta(ResourceMeta, flask.views.MethodViewType):
99
pass
1010

1111
class MethodResource(six.with_metaclass(MethodResourceMeta, flask.views.MethodView)):
1212
"""Subclass of `MethodView` that uses the `ResourceMeta` metaclass. Behaves
13-
exactly like `MethodView` but inherits **flask-smore** annotations.
13+
exactly like `MethodView` but inherits **flask-apispec** annotations.
1414
"""
1515
methods = None

pytest.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[pytest]
2-
addopts=--cov flask_smore --cov-report term-missing
2+
addopts=--cov flask_apispec --cov-report term-missing

setup.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,20 @@ def read(fname):
3434
return content
3535

3636
setup(
37-
name='flask-smore',
38-
version=find_version('flask_smore/__init__.py'),
39-
description='Build and document REST APIs with Flask and Smore',
37+
name='flask-apispec',
38+
version=find_version('flask_apispec/__init__.py'),
39+
description='Build and document REST APIs with Flask and apispec',
4040
long_description=read('README.rst'),
4141
author='Joshua Carp',
4242
author_email='[email protected]',
43-
url='https://github.com/jmcarp/flask-smore',
43+
url='https://github.com/jmcarp/flask-apispec',
4444
packages=find_packages(exclude=('test*', )),
45-
package_dir={'flask_smore': 'flask_smore'},
45+
package_dir={'flask_apispec': 'flask_apispec'},
4646
include_package_data=True,
4747
install_requires=REQUIRES,
4848
license=read('LICENSE'),
4949
zip_safe=False,
50-
keywords='flask marshmallow webargs smore',
50+
keywords='flask marshmallow webargs apispec',
5151
classifiers=[
5252
'Development Status :: 2 - Pre-Alpha',
5353
'Intended Audience :: Developers',

tests/test_paths.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3-
from flask_smore.paths import rule_to_path, rule_to_params
3+
from flask_apispec.paths import rule_to_path, rule_to_params
44

55
def make_rule(app, path, **kwargs):
66
@app.route(path, **kwargs)

tests/test_swagger.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
from marshmallow import fields, Schema
77
from flask import make_response
88

9-
from flask_smore.paths import rule_to_params
10-
from flask_smore.views import MethodResource
11-
from flask_smore import doc, use_kwargs, marshal_with
12-
from flask_smore.apidoc import ViewConverter, ResourceConverter
9+
from flask_apispec.paths import rule_to_params
10+
from flask_apispec.views import MethodResource
11+
from flask_apispec import doc, use_kwargs, marshal_with
12+
from flask_apispec.apidoc import ViewConverter, ResourceConverter
1313

1414
@pytest.fixture
1515
def spec():

tests/test_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3-
from flask_smore import utils
3+
from flask_apispec import utils
44

55
class TestAnnotations:
66

tests/test_views.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
from flask import make_response
44
from marshmallow import fields, Schema
55

6-
from flask_smore.utils import Ref
7-
from flask_smore.views import MethodResource
8-
from flask_smore import doc, use_kwargs, marshal_with
6+
from flask_apispec.utils import Ref
7+
from flask_apispec.views import MethodResource
8+
from flask_apispec import doc, use_kwargs, marshal_with
99

1010
class TestFunctionViews:
1111

@@ -78,13 +78,13 @@ class ChildResource(BaseResource):
7878
def get(self, **kwargs):
7979
return kwargs
8080

81-
assert not any(MethodResource.__smore__.values())
81+
assert not any(MethodResource.__apispec__.values())
8282

83-
assert BaseResource.__smore__['docs'][0].options[0]['tags'] == ['base']
84-
assert ChildResource.__smore__['docs'][0].options[0]['tags'] == ['child']
83+
assert BaseResource.__apispec__['docs'][0].options[0]['tags'] == ['base']
84+
assert ChildResource.__apispec__['docs'][0].options[0]['tags'] == ['child']
8585

86-
assert BaseResource.get.__smore__['docs'][0].options[0]['description'] == 'parent'
87-
assert ChildResource.get.__smore__['docs'][0].options[0]['description'] == 'child'
86+
assert BaseResource.get.__apispec__['docs'][0].options[0]['description'] == 'parent'
87+
assert ChildResource.get.__apispec__['docs'][0].options[0]['description'] == 'child'
8888

8989
def test_inheritance_only_http_methods(self, app):
9090
@use_kwargs({'genre': fields.Str()})

0 commit comments

Comments
 (0)