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

No operations defined in spec! #66

Open
renektonwu opened this issue Nov 10, 2021 · 12 comments
Open

No operations defined in spec! #66

renektonwu opened this issue Nov 10, 2021 · 12 comments

Comments

@renektonwu
Copy link

I follow the echo-wagger README tutorial and get the error bellow
image
And I google so many times and have no answer. so any help or suggesions would be appreciate.

@FunnyEnd
Copy link

I caught the same issue.
the previous version is working fine for me.

go get github.com/swaggo/echo-swagger/tree/v1.1.4

@ghost
Copy link

ghost commented Nov 29, 2021

Because you are using the wrong file to init your documentation. Moreover, I observed a very silly mistake I stuck with while generating docs, the line gap between doc statements and function declaration would fail including swagger for that API.

@ElForastero
Copy link

ElForastero commented Feb 19, 2022

I had a similar issue.

Please double check if you imported your autogenerated docs package in your main file.

Like this:

// replace it with your package path
_ "github.com/swaggo/echo-swagger/example/docs" // docs is generated by Swag CLI, you have to import it.

@dendianugerah
Copy link

had same problem

1 similar comment
@gricar
Copy link

gricar commented Nov 8, 2022

had same problem

@adrian-sturm
Copy link

adrian-sturm commented Nov 22, 2022

I had some trouble myself getting swaggo to find all my annotations in the project structure.
After fiddling around with the cli a bit I found out that you can specify the file where the main api docs are via the -g myfile.go flag and ALSO you need to include the relative paths to all packages containing swaggo-annotations in the -d flag.
For me this results in the generator-call:
swag init -d pkg/api/,pkg/api/handler/,pkg/model/ -g api.go

And, of course, don't forget to import your generated docs.

Edit: See also this issue

@alikud
Copy link

alikud commented Jan 15, 2023

Same, maybe we should define path with router to swag init or some like that? I run swag init in main, where create Echo object, but i had router in other package

@vsian
Copy link

vsian commented Feb 12, 2023

Because you are using the wrong file to init your documentation. Moreover, I observed a very silly mistake I stuck with while generating docs, the line gap between doc statements and function declaration would fail including swagger for that API.

This helps a lot, can't believe this cost me a whole afternoon .......

@HatemTemimi
Copy link

Because you are using the wrong file to init your documentation. Moreover, I observed a very silly mistake I stuck with while generating docs, the line gap between doc statements and function declaration would fail including swagger for that API.

This should really be mentionned in the docs! Do not keep an empty line between annotations and the api function or it won't parse it, and it also won't say anything about it, so be careful.

@MichaelBonnet
Copy link

I had a similar issue.

Please double check if you imported your autogenerated docs package in your main file.

Like this:

// replace it with your package path
_ "github.com/swaggo/echo-swagger/example/docs" // docs is generated by Swag CLI, you have to import it.

what is a properly done example of this?

@asturm-fe
Copy link

@MichaelBonnet There is nothing more to it than that. By default, swag init will generate the documentation files in a local directory named "/docs". In order to roll out this documentation with your application, you need to import this newly generated directory somewhere in your application (usually in the package where you define the documentation-endpoint for your api).
So if your go-module is named github.com/foo/sample-api and you execute swag init in the root directory of your application, the docs can be imported with _ "github.com/foo/sample-api/docs . Note that you make an unnamed import with _ as you don't specifically reference the imported package in your code.

For a full example on how to define a documentation, refer to the official echo-swagger docs

@ilhamasy
Copy link

ilhamasy commented Jul 26, 2024

If you used in golang, I think you should follow this tutorials:
https://santoshk.dev/posts/2022/how-to-integrate-swagger-ui-in-go-backend-gin-edition/

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

No branches or pull requests