-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Class 'GPBMetadata\ProtocGenSwagger\Options\Annotations' not found #794
Comments
This is because you need to generate a PHP version of the swagger annotations proto file. We're not going to maintain a selection of pre generated files for all supported languages I'm afraid. It should be simple to do it manually. Does that makes sense? |
K, I will give that a try. |
Are there any examples of how compiling the annotations into an individual project would work? I'm trying to use this: protoc --proto_path=$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options \
-I /usr/local/include \
-I $GOPATH/src/github.com/grpc-ecosystem/grpc-gateway \
-I $GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
-I $GOPATH/src \
--php_out=/app/gen/php $GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options/annotations.proto
protoc --proto_path=$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options \
-I /usr/local/include \
-I $GOPATH/src/github.com/grpc-ecosystem/grpc-gateway \
-I $GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
-I $GOPATH/src \
--php_out=/app/gen/php $GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options/openapiv2.proto Both files are created successfully but their namespace is just Even if I manually hack the namespaces and the location of the files. When I try to use one of the messages I receive the error: Fatal error: Unable to load descriptor: Depends on file 'protoc-gen-swagger/options/annotations.proto', but it has not been loaded I suspect there is something I am doing wrong rather than a bug. An example or pointer in the right direction would be great. |
Hey Ethan, unfortunately we don't have any PHP examples in the repo or the docs, and I have no personal experience with the PHP generator, so you may have to ask elsewhere. This is a generic protobuf problem, unrelated to grpc-gateway. |
Thank you for the response on such an old issue. For those landing here from Google (it's the top search result when looking for info about this error). I ended up just splitting the messages into separate |
What version of protobuf and what language are you using?
Version: v3.6.1
Language: PHP 5.6.38
What operating system (Linux, Windows, ...) and version?
CentOS Linux release 7.5.1804 (Core)
What runtime / compiler are you using (e.g., python version or gcc version)
PHP 5.6.38 (cli) (built: Sep 12 2018 08:52:18)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
What did you do?
I use GRPC Gateway (https://github.com/grpc-ecosystem/grpc-gateway), generate code for Go and PHP. Go code works well. But I get the error for PHP:
PHP Fatal error: Class 'GPBMetadata\ProtocGenSwagger\Options\Annotations' not found
My *.proto file:
Generated php file with metadata:
My composer.json:
What did you expect to see
I expect to have working generated code and to have GPBMetadata\ProtocGenSwagger\Options\Annotations on any of my composer packages but I don't have it.
What did you see instead?
I see the fatal error and I really couldn't find this class anywhere on Github. Maybe I didn't add some additional composer package? If yes, I don't see any docs about this point.
If you need more info, please ask.
The text was updated successfully, but these errors were encountered: