Repository: Kinto/kinto

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 


Discussion:
Which deploy are you using? The swagger validator seems to pass on the dev server as well as with the 7.0.0dev. Can you give me some details about the deploy you are using? Are there any plugins enabled?

https://online.swagger.io/validator/debug?url=https://kinto.dev.mozaws.net/v1/__api__

The provided Smwogger code example also seems to work with the current master and the dev server. 
The one on staging is the one we're having problems with
Is it https://kinto.dev.mozaws.net/ ? It seems to pass swagger validator and I was able to use the smwogger release version with it. Can you confirm the result?

```python
>>> import asyncio
>>> from smwogger import API
>>> 
>>> 
>>> async def print_operations():
...     async with API('https://kinto.dev.mozaws.net/v1/__api__') as api:
...         print(api.operations)
... 
>>> loop = asyncio.get_event_loop()
>>> try:
...     loop.run_until_complete(print_operations())
... finally:
...     loop.close()
... 
['__heartbeat__', '__lbheartbeat__', '__version__', 'batch', 'contribute', 'create_attachment', 'create_bucket', 'create_collection', 'create_flush', 'create_group', 'create_portier-login', 'create_portier-verify', 'create_record', 'create_stepfunction', 'delete_attachment', 'delete_bucket', 'delete_buckets', 'delete_collection', 'delete_collections', 'delete_group', 'delete_groups', 'delete_history', 'delete_record', 'delete_records', 'get_bucket', 'get_buckets', 'get_changess', 'get_collection', 'get_collections', 'get_fxa-oauth-login', 'get_fxa-oauth-params', 'get_fxa-oauth-token', 'get_group', 'get_groups', 'get_history', 'get_openapi_spec', 'get_permissionss', 'get_record', 'get_records', 'patch_bucket', 'patch_collection', 'patch_group', 'patch_record', 'server_info', 'update_bucket', 'update_collection', 'update_group', 'update_record']

```
No, it's https://kinto.stage.mozaws.net
@gabisurita note that the swagger validator at swagger.io passes even with this issue, as it seems more relax on this problem for some reason.
I got it. It's related to the blocklist plugin. I'll investigated it.

Related to: https://github.com/Cornices/cornice.ext.swagger/issues/68
Which deploy are you using? The swagger validator seems to pass on the dev server as well as with the 7.0.0dev. Can you give me some details about the deploy you are using? Are there any plugins enabled?

https://online.swagger.io/validator/debug?url=https://kinto.dev.mozaws.net/v1/__api__

The provided Smwogger code example also seems to work with the current master and the dev server. 
The one on staging is the one we're having problems with
Is it https://kinto.dev.mozaws.net/ ? It seems to pass swagger validator and I was able to use the smwogger release version with it. Can you confirm the result?

```python
>>> import asyncio
>>> from smwogger import API
>>> 
>>> 
>>> async def print_operations():
...     async with API('https://kinto.dev.mozaws.net/v1/__api__') as api:
...         print(api.operations)
... 
>>> loop = asyncio.get_event_loop()
>>> try:
...     loop.run_until_complete(print_operations())
... finally:
...     loop.close()
... 
['__heartbeat__', '__lbheartbeat__', '__version__', 'batch', 'contribute', 'create_attachment', 'create_bucket', 'create_collection', 'create_flush', 'create_group', 'create_portier-login', 'create_portier-verify', 'create_record', 'create_stepfunction', 'delete_attachment', 'delete_bucket', 'delete_buckets', 'delete_collection', 'delete_collections', 'delete_group', 'delete_groups', 'delete_history', 'delete_record', 'delete_records', 'get_bucket', 'get_buckets', 'get_changess', 'get_collection', 'get_collections', 'get_fxa-oauth-login', 'get_fxa-oauth-params', 'get_fxa-oauth-token', 'get_group', 'get_groups', 'get_history', 'get_openapi_spec', 'get_permissionss', 'get_record', 'get_records', 'patch_bucket', 'patch_collection', 'patch_group', 'patch_record', 'server_info', 'update_bucket', 'update_collection', 'update_group', 'update_record']

```
No, it's https://kinto.stage.mozaws.net
@gabisurita note that the swagger validator at swagger.io passes even with this issue, as it seems more relax on this problem for some reason.
I got it. It's related to the blocklist plugin. I'll investigated it.

Related to: https://github.com/Cornices/cornice.ext.swagger/issues/68

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -20,7 +20,7 @@ def read_file(filename):
     '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.


Test patch: