Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swagger spec still invalid #1180

Closed
tarekziade opened this issue Apr 4, 2017 · 8 comments
Closed

Swagger spec still invalid #1180

tarekziade opened this issue Apr 4, 2017 · 8 comments
Assignees
Labels

Comments

@tarekziade
Copy link
Contributor

The Swagger spec is still invalid it seems

Extract:

/{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

/{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:

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

@leplatrem leplatrem added the bug label Apr 4, 2017
@gabisurita
Copy link
Member

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__

@gabisurita
Copy link
Member

The provided Smwogger code example also seems to work with the current master and the dev server.

@chartjes
Copy link

chartjes commented Apr 4, 2017

The one on staging is the one we're having problems with

@gabisurita gabisurita self-assigned this Apr 4, 2017
@gabisurita
Copy link
Member

gabisurita commented Apr 4, 2017

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?

>>> 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']

@chartjes
Copy link

chartjes commented Apr 4, 2017

No, it's https://kinto.stage.mozaws.net

@tarekziade
Copy link
Contributor Author

@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.

@gabisurita
Copy link
Member

gabisurita commented Apr 4, 2017

I got it. It's related to the blocklist plugin. I'll investigated it.

Related to: Cornices/cornice.ext.swagger#68

@leplatrem
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants