We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Swagger spec still invalid
The Swagger spec is still invalid it seems

Extract:

```json
/{prefix}/{api_ver:\\d+}/{application_guid}/{application_ver}/{metrics:.*}": {
      "parameters": [
        {
          "name": "prefix",
          "type": "string",
          "required": true,
          "in": "path"
        },
        {
          "name": "api_ver:\\d+",
          "type": "string",
          "required": true,
          "in": "path"
        },
        {
          "name": "application_guid",
          "type": "string",
          "required": true,
          "in": "path"
        },
        {
          "name": "application_ver",
          "type": "string",
          "required": true,
          "in": "path"
        },
        {
          "name": "metrics:.*",
          "type": "string",
          "required": true,
          "in": "path"
        }
      ],
```

In this API definitions, smwogger will choke on api_ver and metrics because their definitions in the parameter list should not include the regexp and just be the name of the parameter

The right definition should be

```json
/{prefix}/{api_ver:\\d+}/{application_guid}/{application_ver}/{metrics:.*}": {
      "parameters": [
        {
          "name": "prefix",
          "type": "string",
          "required": true,
          "in": "path"
        },
        {
          "name": "api_ver",
          "type": "string",
          "required": true,
          "in": "path"
        },
        {
          "name": "application_guid",
          "type": "string",
          "required": true,
          "in": "path"
        },
        {
          "name": "application_ver",
          "type": "string",
          "required": true,
          "in": "path"
        },
        {
          "name": "metrics",
          "type": "string",
          "required": true,
          "in": "path"
        }
      ],
```

To validate that it works, you can try this small program with Smowgger to print all operations:

```python
import asyncio
from smwogger import API


async def print_operations():
    async with API('http://path.to.kinto/v1/__api__') as api:
        print(api.operations)

loop = asyncio.get_event_loop()
try:
    loop.run_until_complete(print_operations())
finally:
    loop.close()
```


cc @gabisurita @chartjes 
Swagger spec still invalid
The Swagger spec is still invalid it seems

Extract:

```json
/{prefix}/{api_ver:\\d+}/{application_guid}/{application_ver}/{metrics:.*}": {
      "parameters": [
        {
          "name": "prefix",
          "type": "string",
          "required": true,
          "in": "path"
        },
        {
          "name": "api_ver:\\d+",
          "type": "string",
          "required": true,
          "in": "path"
        },
        {
          "name": "application_guid",
          "type": "string",
          "required": true,
          "in": "path"
        },
        {
          "name": "application_ver",
          "type": "string",
          "required": true,
          "in": "path"
        },
        {
          "name": "metrics:.*",
          "type": "string",
          "required": true,
          "in": "path"
        }
      ],
```

In this API definitions, smwogger will choke on api_ver and metrics because their definitions in the parameter list should not include the regexp and just be the name of the parameter

The right definition should be

```json
/{prefix}/{api_ver:\\d+}/{application_guid}/{application_ver}/{metrics:.*}": {
      "parameters": [
        {
          "name": "prefix",
          "type": "string",
          "required": true,
          "in": "path"
        },
        {
          "name": "api_ver",
          "type": "string",
          "required": true,
          "in": "path"
        },
        {
          "name": "application_guid",
          "type": "string",
          "required": true,
          "in": "path"
        },
        {
          "name": "application_ver",
          "type": "string",
          "required": true,
          "in": "path"
        },
        {
          "name": "metrics",
          "type": "string",
          "required": true,
          "in": "path"
        }
      ],
```

To validate that it works, you can try this small program with Smowgger to print all operations:

```python
import asyncio
from smwogger import API


async def print_operations():
    async with API('http://path.to.kinto/v1/__api__') as api:
        print(api.operations)

loop = asyncio.get_event_loop()
try:
    loop.run_until_complete(print_operations())
finally:
    loop.close()
```


cc @gabisurita @chartjes 

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `setup.py`
Content:
```
1 import codecs
2 import os
3 from setuptools import setup, find_packages
4 
5 here = os.path.abspath(os.path.dirname(__file__))
6 
7 
8 def read_file(filename):
9     """Open a related file and return its content."""
10     with codecs.open(os.path.join(here, filename), encoding='utf-8') as f:
11         content = f.read()
12     return content
13 
14 
15 README = read_file('README.rst')
16 CHANGELOG = read_file('CHANGELOG.rst')
17 CONTRIBUTORS = read_file('CONTRIBUTORS.rst')
18 
19 REQUIREMENTS = [
20     'bcrypt',
21     'colander >= 1.3.2',
22     'cornice >= 2.4',
23     'cornice_swagger >= 0.5',
24     'jsonschema',
25     'jsonpatch',
26     'logging-color-formatter >= 1.0.1',  # Message interpolations.
27     'python-dateutil',
28     'pyramid > 1.8',
29     'pyramid_multiauth >= 0.8',  # User on policy selected event.
30     'transaction',
31     'pyramid_tm',
32     'requests',
33     'waitress',
34     'ujson >= 1.35'
35 ]
36 
37 POSTGRESQL_REQUIRES = [
38     'SQLAlchemy',
39     'psycopg2 > 2.5',
40     'zope.sqlalchemy',
41 ]
42 
43 REDIS_REQUIRES = [
44     'kinto_redis'
45 ]
46 
47 SETUP_REQUIRES = [
48     'pytest-runner'
49 ]
50 
51 TEST_REQUIREMENTS = [
52     'bravado_core',
53     'pytest',
54     'WebTest'
55 ]
56 
57 DEPENDENCY_LINKS = [
58 ]
59 
60 MONITORING_REQUIRES = [
61     'raven',
62     'statsd',
63     'newrelic',
64     'werkzeug',
65 ]
66 
67 ENTRY_POINTS = {
68     'paste.app_factory': [
69         'main = kinto:main',
70     ],
71     'console_scripts': [
72         'kinto = kinto.__main__:main'
73     ],
74 }
75 
76 
77 setup(name='kinto',
78       version='7.0.0.dev0',
79       description='Kinto Web Service - Store, Sync, Share, and Self-Host.',
80       long_description="{}\n\n{}\n\n{}".format(README, CHANGELOG, CONTRIBUTORS),
81       license='Apache License (2.0)',
82       classifiers=[
83           "Programming Language :: Python",
84           "Programming Language :: Python :: 3",
85           "Programming Language :: Python :: 3.5",
86           "Programming Language :: Python :: 3.6",
87           "Programming Language :: Python :: Implementation :: CPython",
88           "Topic :: Internet :: WWW/HTTP",
89           "Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
90           "License :: OSI Approved :: Apache Software License"
91       ],
92       keywords="web sync json storage services",
93       author='Mozilla Services',
94       author_email='storage-team@mozilla.com',
95       url='https://github.com/Kinto/kinto',
96       packages=find_packages(),
97       package_data={'': ['*.rst', '*.py', '*.yaml']},
98       include_package_data=True,
99       zip_safe=False,
100       setup_requires=SETUP_REQUIRES,
101       tests_require=TEST_REQUIREMENTS,
102       install_requires=REQUIREMENTS,
103       extras_require={
104           'redis': REDIS_REQUIRES,
105           'postgresql': POSTGRESQL_REQUIRES,
106           'monitoring': MONITORING_REQUIRES,
107       },
108       test_suite="tests",
109       dependency_links=DEPENDENCY_LINKS,
110       entry_points=ENTRY_POINTS)
111
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -20,7 +20,7 @@
     'bcrypt',
     'colander >= 1.3.2',
     'cornice >= 2.4',
-    'cornice_swagger >= 0.5',
+    'cornice_swagger >= 0.5.1',
     'jsonschema',
     'jsonpatch',
     'logging-color-formatter >= 1.0.1',  # Message interpolations.

{"golden_diff": "diff --git a/setup.py b/setup.py\n--- a/setup.py\n+++ b/setup.py\n@@ -20,7 +20,7 @@\n     'bcrypt',\n     'colander >= 1.3.2',\n     'cornice >= 2.4',\n-    'cornice_swagger >= 0.5',\n+    'cornice_swagger >= 0.5.1',\n     'jsonschema',\n     'jsonpatch',\n     'logging-color-formatter >= 1.0.1',  # Message interpolations.\n", "issue": "Swagger spec still invalid\nThe Swagger spec is still invalid it seems\r\n\r\nExtract:\r\n\r\n```json\r\n/{prefix}/{api_ver:\\\\d+}/{application_guid}/{application_ver}/{metrics:.*}\": {\r\n      \"parameters\": [\r\n        {\r\n          \"name\": \"prefix\",\r\n          \"type\": \"string\",\r\n          \"required\": true,\r\n          \"in\": \"path\"\r\n        },\r\n        {\r\n          \"name\": \"api_ver:\\\\d+\",\r\n          \"type\": \"string\",\r\n          \"required\": true,\r\n          \"in\": \"path\"\r\n        },\r\n        {\r\n          \"name\": \"application_guid\",\r\n          \"type\": \"string\",\r\n          \"required\": true,\r\n          \"in\": \"path\"\r\n        },\r\n        {\r\n          \"name\": \"application_ver\",\r\n          \"type\": \"string\",\r\n          \"required\": true,\r\n          \"in\": \"path\"\r\n        },\r\n        {\r\n          \"name\": \"metrics:.*\",\r\n          \"type\": \"string\",\r\n          \"required\": true,\r\n          \"in\": \"path\"\r\n        }\r\n      ],\r\n```\r\n\r\nIn this API definitions, smwogger will choke on api_ver and metrics because their definitions in the parameter list should not include the regexp and just be the name of the parameter\r\n\r\nThe right definition should be\r\n\r\n```json\r\n/{prefix}/{api_ver:\\\\d+}/{application_guid}/{application_ver}/{metrics:.*}\": {\r\n      \"parameters\": [\r\n        {\r\n          \"name\": \"prefix\",\r\n          \"type\": \"string\",\r\n          \"required\": true,\r\n          \"in\": \"path\"\r\n        },\r\n        {\r\n          \"name\": \"api_ver\",\r\n          \"type\": \"string\",\r\n          \"required\": true,\r\n          \"in\": \"path\"\r\n        },\r\n        {\r\n          \"name\": \"application_guid\",\r\n          \"type\": \"string\",\r\n          \"required\": true,\r\n          \"in\": \"path\"\r\n        },\r\n        {\r\n          \"name\": \"application_ver\",\r\n          \"type\": \"string\",\r\n          \"required\": true,\r\n          \"in\": \"path\"\r\n        },\r\n        {\r\n          \"name\": \"metrics\",\r\n          \"type\": \"string\",\r\n          \"required\": true,\r\n          \"in\": \"path\"\r\n        }\r\n      ],\r\n```\r\n\r\nTo validate that it works, you can try this small program with Smowgger to print all operations:\r\n\r\n```python\r\nimport asyncio\r\nfrom smwogger import API\r\n\r\n\r\nasync def print_operations():\r\n    async with API('http://path.to.kinto/v1/__api__') as api:\r\n        print(api.operations)\r\n\r\nloop = asyncio.get_event_loop()\r\ntry:\r\n    loop.run_until_complete(print_operations())\r\nfinally:\r\n    loop.close()\r\n```\r\n\r\n\r\ncc @gabisurita @chartjes \nSwagger spec still invalid\nThe Swagger spec is still invalid it seems\r\n\r\nExtract:\r\n\r\n```json\r\n/{prefix}/{api_ver:\\\\d+}/{application_guid}/{application_ver}/{metrics:.*}\": {\r\n      \"parameters\": [\r\n        {\r\n          \"name\": \"prefix\",\r\n          \"type\": \"string\",\r\n          \"required\": true,\r\n          \"in\": \"path\"\r\n        },\r\n        {\r\n          \"name\": \"api_ver:\\\\d+\",\r\n          \"type\": \"string\",\r\n          \"required\": true,\r\n          \"in\": \"path\"\r\n        },\r\n        {\r\n          \"name\": \"application_guid\",\r\n          \"type\": \"string\",\r\n          \"required\": true,\r\n          \"in\": \"path\"\r\n        },\r\n        {\r\n          \"name\": \"application_ver\",\r\n          \"type\": \"string\",\r\n          \"required\": true,\r\n          \"in\": \"path\"\r\n        },\r\n        {\r\n          \"name\": \"metrics:.*\",\r\n          \"type\": \"string\",\r\n          \"required\": true,\r\n          \"in\": \"path\"\r\n        }\r\n      ],\r\n```\r\n\r\nIn this API definitions, smwogger will choke on api_ver and metrics because their definitions in the parameter list should not include the regexp and just be the name of the parameter\r\n\r\nThe right definition should be\r\n\r\n```json\r\n/{prefix}/{api_ver:\\\\d+}/{application_guid}/{application_ver}/{metrics:.*}\": {\r\n      \"parameters\": [\r\n        {\r\n          \"name\": \"prefix\",\r\n          \"type\": \"string\",\r\n          \"required\": true,\r\n          \"in\": \"path\"\r\n        },\r\n        {\r\n          \"name\": \"api_ver\",\r\n          \"type\": \"string\",\r\n          \"required\": true,\r\n          \"in\": \"path\"\r\n        },\r\n        {\r\n          \"name\": \"application_guid\",\r\n          \"type\": \"string\",\r\n          \"required\": true,\r\n          \"in\": \"path\"\r\n        },\r\n        {\r\n          \"name\": \"application_ver\",\r\n          \"type\": \"string\",\r\n          \"required\": true,\r\n          \"in\": \"path\"\r\n        },\r\n        {\r\n          \"name\": \"metrics\",\r\n          \"type\": \"string\",\r\n          \"required\": true,\r\n          \"in\": \"path\"\r\n        }\r\n      ],\r\n```\r\n\r\nTo validate that it works, you can try this small program with Smowgger to print all operations:\r\n\r\n```python\r\nimport asyncio\r\nfrom smwogger import API\r\n\r\n\r\nasync def print_operations():\r\n    async with API('http://path.to.kinto/v1/__api__') as api:\r\n        print(api.operations)\r\n\r\nloop = asyncio.get_event_loop()\r\ntry:\r\n    loop.run_until_complete(print_operations())\r\nfinally:\r\n    loop.close()\r\n```\r\n\r\n\r\ncc @gabisurita @chartjes \n", "before_files": [{"content": "import codecs\nimport os\nfrom setuptools import setup, find_packages\n\nhere = os.path.abspath(os.path.dirname(__file__))\n\n\ndef read_file(filename):\n    \"\"\"Open a related file and return its content.\"\"\"\n    with codecs.open(os.path.join(here, filename), encoding='utf-8') as f:\n        content = f.read()\n    return content\n\n\nREADME = read_file('README.rst')\nCHANGELOG = read_file('CHANGELOG.rst')\nCONTRIBUTORS = read_file('CONTRIBUTORS.rst')\n\nREQUIREMENTS = [\n    'bcrypt',\n    'colander >= 1.3.2',\n    'cornice >= 2.4',\n    'cornice_swagger >= 0.5',\n    'jsonschema',\n    'jsonpatch',\n    'logging-color-formatter >= 1.0.1',  # Message interpolations.\n    'python-dateutil',\n    'pyramid > 1.8',\n    'pyramid_multiauth >= 0.8',  # User on policy selected event.\n    'transaction',\n    'pyramid_tm',\n    'requests',\n    'waitress',\n    'ujson >= 1.35'\n]\n\nPOSTGRESQL_REQUIRES = [\n    'SQLAlchemy',\n    'psycopg2 > 2.5',\n    'zope.sqlalchemy',\n]\n\nREDIS_REQUIRES = [\n    'kinto_redis'\n]\n\nSETUP_REQUIRES = [\n    'pytest-runner'\n]\n\nTEST_REQUIREMENTS = [\n    'bravado_core',\n    'pytest',\n    'WebTest'\n]\n\nDEPENDENCY_LINKS = [\n]\n\nMONITORING_REQUIRES = [\n    'raven',\n    'statsd',\n    'newrelic',\n    'werkzeug',\n]\n\nENTRY_POINTS = {\n    'paste.app_factory': [\n        'main = kinto:main',\n    ],\n    'console_scripts': [\n        'kinto = kinto.__main__:main'\n    ],\n}\n\n\nsetup(name='kinto',\n      version='7.0.0.dev0',\n      description='Kinto Web Service - Store, Sync, Share, and Self-Host.',\n      long_description=\"{}\\n\\n{}\\n\\n{}\".format(README, CHANGELOG, CONTRIBUTORS),\n      license='Apache License (2.0)',\n      classifiers=[\n          \"Programming Language :: Python\",\n          \"Programming Language :: Python :: 3\",\n          \"Programming Language :: Python :: 3.5\",\n          \"Programming Language :: Python :: 3.6\",\n          \"Programming Language :: Python :: Implementation :: CPython\",\n          \"Topic :: Internet :: WWW/HTTP\",\n          \"Topic :: Internet :: WWW/HTTP :: WSGI :: Application\",\n          \"License :: OSI Approved :: Apache Software License\"\n      ],\n      keywords=\"web sync json storage services\",\n      author='Mozilla Services',\n      author_email='storage-team@mozilla.com',\n      url='https://github.com/Kinto/kinto',\n      packages=find_packages(),\n      package_data={'': ['*.rst', '*.py', '*.yaml']},\n      include_package_data=True,\n      zip_safe=False,\n      setup_requires=SETUP_REQUIRES,\n      tests_require=TEST_REQUIREMENTS,\n      install_requires=REQUIREMENTS,\n      extras_require={\n          'redis': REDIS_REQUIRES,\n          'postgresql': POSTGRESQL_REQUIRES,\n          'monitoring': MONITORING_REQUIRES,\n      },\n      test_suite=\"tests\",\n      dependency_links=DEPENDENCY_LINKS,\n      entry_points=ENTRY_POINTS)\n", "path": "setup.py"}], "after_files": [{"content": "import codecs\nimport os\nfrom setuptools import setup, find_packages\n\nhere = os.path.abspath(os.path.dirname(__file__))\n\n\ndef read_file(filename):\n    \"\"\"Open a related file and return its content.\"\"\"\n    with codecs.open(os.path.join(here, filename), encoding='utf-8') as f:\n        content = f.read()\n    return content\n\n\nREADME = read_file('README.rst')\nCHANGELOG = read_file('CHANGELOG.rst')\nCONTRIBUTORS = read_file('CONTRIBUTORS.rst')\n\nREQUIREMENTS = [\n    'bcrypt',\n    'colander >= 1.3.2',\n    'cornice >= 2.4',\n    'cornice_swagger >= 0.5.1',\n    'jsonschema',\n    'jsonpatch',\n    'logging-color-formatter >= 1.0.1',  # Message interpolations.\n    'python-dateutil',\n    'pyramid > 1.8',\n    'pyramid_multiauth >= 0.8',  # User on policy selected event.\n    'transaction',\n    'pyramid_tm',\n    'requests',\n    'waitress',\n    'ujson >= 1.35'\n]\n\nPOSTGRESQL_REQUIRES = [\n    'SQLAlchemy',\n    'psycopg2 > 2.5',\n    'zope.sqlalchemy',\n]\n\nREDIS_REQUIRES = [\n    'kinto_redis'\n]\n\nSETUP_REQUIRES = [\n    'pytest-runner'\n]\n\nTEST_REQUIREMENTS = [\n    'bravado_core',\n    'pytest',\n    'WebTest'\n]\n\nDEPENDENCY_LINKS = [\n]\n\nMONITORING_REQUIRES = [\n    'raven',\n    'statsd',\n    'newrelic',\n    'werkzeug',\n]\n\nENTRY_POINTS = {\n    'paste.app_factory': [\n        'main = kinto:main',\n    ],\n    'console_scripts': [\n        'kinto = kinto.__main__:main'\n    ],\n}\n\n\nsetup(name='kinto',\n      version='7.0.0.dev0',\n      description='Kinto Web Service - Store, Sync, Share, and Self-Host.',\n      long_description=\"{}\\n\\n{}\\n\\n{}\".format(README, CHANGELOG, CONTRIBUTORS),\n      license='Apache License (2.0)',\n      classifiers=[\n          \"Programming Language :: Python\",\n          \"Programming Language :: Python :: 3\",\n          \"Programming Language :: Python :: 3.5\",\n          \"Programming Language :: Python :: 3.6\",\n          \"Programming Language :: Python :: Implementation :: CPython\",\n          \"Topic :: Internet :: WWW/HTTP\",\n          \"Topic :: Internet :: WWW/HTTP :: WSGI :: Application\",\n          \"License :: OSI Approved :: Apache Software License\"\n      ],\n      keywords=\"web sync json storage services\",\n      author='Mozilla Services',\n      author_email='storage-team@mozilla.com',\n      url='https://github.com/Kinto/kinto',\n      packages=find_packages(),\n      package_data={'': ['*.rst', '*.py', '*.yaml']},\n      include_package_data=True,\n      zip_safe=False,\n      setup_requires=SETUP_REQUIRES,\n      tests_require=TEST_REQUIREMENTS,\n      install_requires=REQUIREMENTS,\n      extras_require={\n          'redis': REDIS_REQUIRES,\n          'postgresql': POSTGRESQL_REQUIRES,\n          'monitoring': MONITORING_REQUIRES,\n      },\n      test_suite=\"tests\",\n      dependency_links=DEPENDENCY_LINKS,\n      entry_points=ENTRY_POINTS)\n", "path": "setup.py"}]}