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

compatible with swagger 2? #94

Open
tommyjcarpenter opened this issue Mar 21, 2016 · 14 comments
Open

compatible with swagger 2? #94

tommyjcarpenter opened this issue Mar 21, 2016 · 14 comments
Labels

Comments

@tommyjcarpenter
Copy link

When I stub out a new project according to the readme and head to http://localhost:5000/api/spec.html#!/spec, I don't see anything where the dropdown endpoints would show. I'm trying to debug this.

When I click raw, I get a json with all of the models and info I added using the decorators. When I paste that JSON into http://editor.swagger.io/#/, I get:

✖ Swagger Error
Missing required property: paths
Jump to line 0
Details
 Object
✖ Swagger Error
Missing required property: info
Jump to line 0
Details
 Object
✖ Swagger Error
Missing required property: swagger
Jump to line 0
Details
 Object

Any ideas?

@sobolevn
Copy link
Contributor

You are on top of our stuff, right now we only support swagger 1.2, which is kind of outdated. but we are building the new version for new versions also. Here's the link to keep you informed (it will be merged soon): https://github.com/flask-restful-swagger/flask-restful-swagger

When pasting to online validator, it validates against 2.0 specs. And fails for older ones.

@tommyjcarpenter
Copy link
Author

@sobolevn thanks for your response!

is there another way I can figure out what I did wrong then? On the main API page I just see: spec : test Show/Hide List Operations Expand Operations Raw [ base url: http://localhost:5000/api/spec/_/resource_list.json , api version: 0.1 ]

but when I click "Raw" I see models, APIs, the whole shebang.

@sobolevn
Copy link
Contributor

@tommyjcarpenter can you please upload a sceenshot?

@tommyjcarpenter
Copy link
Author

@sobolevn Here are screenshots:

http://s16.postimg.org/dgg4webd1/Screen_Shot_2016_03_22_at_8_37_14_AM.png

http://s16.postimg.org/tu4ptagw5/Screen_Shot_2016_03_22_at_8_37_19_AM.png

First screenshot is the missing swagger endpoints, second is what I see when I click raw.

The only thing I did to my project was add

###################################
# Wrap the Api with swagger.docs. It is a thin wrapper around the Api class that adds some swagger
# smarts
api = swagger.docs(Api(app), apiVersion='0.1')
###################################

And the example @swagger.operation annotation you have in your readme.

@sobolevn
Copy link
Contributor

What happens when you press Show/ Hide? Any errors in the console?

@tommyjcarpenter
Copy link
Author

Nothing happens, no errors. The only thing I can see is the url changes to http://localhost:5000/api/spec.html#!/spec instead of http://localhost:5000/api/spec.html

@tommyjcarpenter
Copy link
Author

Flask logs show all 200s

@sobolevn sobolevn reopened this Mar 22, 2016
@tommyjcarpenter
Copy link
Author

A bit hasty to close issues with "invalid" on people trying to use your library there

On Mar 22, 2016, at 8:57 AM, Sobolev Nikita [email protected] wrote:

Reopened #94.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub

@sobolevn
Copy link
Contributor

I guess, I have managed to repeat you issue. Here's my json, which I had when the issue was pretty similar to yours: http://pastie.org/10769893

As you can see, it's pretty similar. But, we are missing the dataType parameter. The difference is, that I'm having an issue in the console. http://i.imgur.com/1z1Nxbi.png

Fixed json: http://pastie.org/10769890#15
To fix your code, add this line:

@swagger.operation(
        ...
        parameters=[
            {
              ...
              "dataType": "string",  # here
           }

Does this help?

@tommyjcarpenter
Copy link
Author

Will try it out later, thanks. Yes you had something like ModelClass in the README but I didn't know what that referred to, and later you had ModelClass2, so I just removed those lines. Maybe add a note to the readme that this parameter is required and what ModelClass is.

Or maybe add string as a default for dataType?

@sobolevn
Copy link
Contributor

Thank you, sure.

@tommyjcarpenter
Copy link
Author

Still not seeing the API. My JSON now looks like:

{
    "apiVersion": "0.1",
    "apis": [
        {
            "description": "Describing elephants",
            "notes": null,
            "operations": [
                {
                    "method": "post",
                    "nickname": "upload",
                    "notes": "some really good notes",
                    "parameters": [
                        {
                            "allowMultiple": false,
                            "dataType": "string",
                            "description": "blueprint object that needs to be added. YAML.",
                            "name": "body",
                            "paramType": "body",
                            "required": true
                        }
                    ],
                    "responseMessages": [
                        {
                            "code": 201,
                            "message": "Created. The URL of the created blueprint should be in the Location header"
                        },
                        {
                            "code": 405,
                            "message": "Invalid input"
                        }
                    ],
                    "summary": null
                }
            ],
            "path": "/Docker"
        }
    ],
    "basePath": "http://localhost:5000",
    "description": "Auto generated API docs by flask-restful-swagger",
    "models": {},
    "produces": [
        "application/json"
    ],
    "resourcePath": "/",
    "spec_endpoint_path": "/api/spec",
    "swaggerVersion": "1.2"
}

@sobolevn
Copy link
Contributor

I have managed to create the same json, as you have: http://pastie.org/10770850

But, it is working for me. Please, show me the full code you have, maybe the issue is there.

@tommyjcarpenter
Copy link
Author

That is difficult, because this was part of a work application, which I cannot post here. I have switched to https://github.com/gangverk/flask-swagger in the meantime. I will re-read your documentation afterwards.

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

2 participants