gin-swagger icon indicating copy to clipboard operation
gin-swagger copied to clipboard

No operations defined in spec!

Open kotyara85 opened this issue 6 years ago • 7 comments

Hello, Having this issue - No operations defined in spec! json file is accessiable: http://localhost:8081/swagger/doc.json

{
    "swagger": "2.0",
    "info": {
        "description": "This is a sample server Petstore server.",
        "title": "Test api",
        "termsOfService": "http://swagger.io/terms/",
        "contact": {
            "name": "API Support",
            "url": "http://www.swagger.io/support",
            "email": "[email protected]"
        },
        "license": {
            "name": "Apache 2.0",
            "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
        },
        "version": "1.0.0"
    },
    "host": "localhost:8081",
    "basePath": "/api",
    "paths": {}
}

I don't see any paths though.

Api itself works just fine.

Is there a way to debug this?

Thanks!

kotyara85 avatar Jun 29 '19 18:06 kotyara85

Hi @kotyara85

Check out this example:

https://github.com/swaggo/swag/blob/master/example/basic/api/api.go#L8

Probably it would require to place the comments for the each API endpoint to generate properly docs.go file.

But I am not 100% sure about that. I've just started the integration myself.

oivoodoo avatar Oct 24 '19 16:10 oivoodoo

In the comments, @Router this must start with ‘/’

gq-tang avatar Nov 13 '19 01:11 gq-tang

Having same issue, getting "No operations defined in spec!" even though my swagger.yaml and swagger.json file is generated correctly. When copy-pasted my YAML file content in http://editor.swagger.io/, it is working as expected but showing the error in http://localhost:8080/swagger/index.html

Anyone know, why this error "No operations defined in spec!" comes up? and what needs to be done in that case

amoghpareek1 avatar May 15 '20 09:05 amoghpareek1

This helped me solve my issue https://github.com/swaggo/gin-swagger/issues/73#issuecomment-523878582

Shailendra-go avatar Jul 20 '23 09:07 Shailendra-go

Have you solved this problem? How did you solve it?

noneowl avatar Jan 20 '24 10:01 noneowl