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

Is it possible to use protoc-gen-swagger options in my own protos? #976

Closed
rmilejcz opened this issue Jul 22, 2019 · 4 comments
Closed

Is it possible to use protoc-gen-swagger options in my own protos? #976

rmilejcz opened this issue Jul 22, 2019 · 4 comments

Comments

@rmilejcz
Copy link

rmilejcz commented Jul 22, 2019

I'm trying to use these: https://github.com/grpc-ecosystem/grpc-gateway/tree/master/protoc-gen-swagger/options

I've seen a few disparate examples of people doing things like:

import "protoc-gen-swagger/options/openapiv2.proto

or:

import "grpc-gateway/protoc-gen-swagger/options/annotations.proto

but I cannot get this to work and it isn't documented anywhere. I assume I could import it via it's package name so long as it can be found in my $GOPATH but this:

import "grpc/gateway/protoc_gen_swagger/options/annotations.proto"

also fails with the error:

file was not found or had errors

I have followed the installation steps to a T and have no issues importing the google options from "google/api/annotations.proto" but the protoc-gen-swagger options are eluding me and without any documentation (that I could find) I'm feeling pretty lost.

@achew22
Copy link
Collaborator

achew22 commented Jul 22, 2019

@rmilejcz, thanks for filing an issue. Sorry you're not having a great time.

[...] I cannot get this to work and it isn't documented anywhere.

and

[...] the protoc-gen-swagger options are eluding me and without any documentation (that I could find) I'm feeling pretty lost.

@rmilejcz, on the home page for the repo, in 24px font it says "Check out our documentation!", could you help me understand the process you took to get here where you concluded that there was no documentation? Further, the homepage (and therefore the README.md) of the repo is self-contained documentation for driving the project.

What have you tried doing? What documentation have you been referring to? Do you have prior experience with proto and protoc? Have you gone through any tutorials on that front to help you understand how protos and their imports work?

My guess is that you're trying to import in a .proto file but haven't manipulated the proto import path as described in section 3 of our usage documentation. Could you share the command you invoked that resulted in this error as well as a complete reproduction of the problem?

@johanbrandhorst
Copy link
Collaborator

@rmilejcz I think your problems at this point are to do with protoc import paths, which is a problem outside the domain of this repo. This repo contains examples of how to use the annotation in your own protofiles, but it assumes some familiarity with protoc. The reason you can use different import paths in your own protofiles is because the path is relative to your provided protoc import paths.

@rmilejcz
Copy link
Author

rmilejcz commented Jul 23, 2019

@johanbrandhorst yeah I made a foolish mistake, the issue was that I failed to update a script unfortunately and I was running code that did not include the protos I wanted via protoc -I. Once I altered the correct script to include:

-I"$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/"

I could properly import without issue

import "protoc-gen-swagger/options/annotations.proto"

All I can say is thanks for being patient and sorry for the ultimately pointless github issue lol

@johanbrandhorst
Copy link
Collaborator

Thanks for getting back to us, we've all made a mistake like that at some point 😄!

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

3 participants