Skip to content

Commit

Permalink
Merge pull request #3362 from fecgov/feature/update-apispec
Browse files Browse the repository at this point in the history
Update apispec package to use fecgov's forked repo
  • Loading branch information
R Vrajmohan committed Sep 19, 2018
2 parents 2192355 + c1efdc2 commit 18131fe
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apispec==0.19.0
git+https://github.com/fecgov/apispec.git@dev#egg=apispec
prance[osv]>=0.11 # use apispec[validation] once we no longer fork apispec
cfenv==0.5.2
invoke==0.15.0
psycopg2==2.7.1
Expand All @@ -24,7 +25,7 @@ elasticsearch-dsl==5.4.0
git+https://github.com/18F/slate.git

# Marshalling
flask-apispec==0.6.0.post0
flask-apispec==0.7.0
marshmallow==2.6.0
marshmallow-sqlalchemy==0.8.0
git+https://github.com/jmcarp/marshmallow-pagination@master
Expand Down
7 changes: 5 additions & 2 deletions tests/test_swagger.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import unittest

from apispec import utils, exceptions

import webservices.rest
import webservices.schemas # needed to generate full spec
from webservices.spec import spec, format_docstring


class TestSwagger(unittest.TestCase):

def test_swagger_valid(self):
try:
utils.validate_swagger(spec)
utils.validate_spec(spec)
except exceptions.SwaggerError as error:
self.fail(str(error))

Expand Down
7 changes: 4 additions & 3 deletions webservices/spec.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from apispec import APISpec
from apispec.ext.marshmallow import MarshmallowPlugin


from webservices import docs
from webservices import __API_VERSION__
Expand All @@ -9,8 +11,6 @@ def format_docstring(docstring):

formatted = []
lines = docstring.expandtabs().splitlines()
indent = min(len(line) - len(line.strip()) for line in lines if line.strip())
trimmed = [lines[0].lstrip()] + [line[indent:].rstrip() for line in lines[1:]]

for line in lines:
if line == '':
Expand All @@ -20,13 +20,14 @@ def format_docstring(docstring):

return ' '.join(formatted).strip()


spec = APISpec(
title='OpenFEC',
version=__API_VERSION__,
info={'description': format_docstring(docs.API_DESCRIPTION)},
basePath='/v1',
produces=['application/json'],
plugins=['apispec.ext.marshmallow'],
plugins=[MarshmallowPlugin()],
securityDefinitions={
'apiKey': {
'type': 'apiKey',
Expand Down

0 comments on commit 18131fe

Please sign in to comment.