Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I configure Google Cloud Endpoints to ignore specific methods during API generation?

How can I configure Google Cloud Endpoints to ignore specific methods during API generation ?

I want to expose some methods (but not all) of my FooServiceImpl service as a Cloud Endpoints API. With an @Api annotation on my FooServiceImpl, Google Cloud Endpoints try to expose ALL public methods (and fails if response class is not OK).

How can I have a public method in my service that Cloud Endpoints will not try to expose in the API ?

A solution would be to have two service classes :

  • FooServiceImpl, that contains implementation method

  • FooServiceApi, that contains only API-exposed methods and each method calls its implementation in FooServiceImpl

But this is a not-ideal and verbose solution, it means we have two classes for each service, with very similar code...

like image 761
mickael.lenormand Avatar asked Jan 19 '26 21:01

mickael.lenormand


1 Answers

Class methods appear in the API surface if:

  • They are annotated with @ApiMethod.
  • They are public and follow a naming convention for a RESTful method name (replace Resource with the name of your JavaBean):
    • getResource
    • insertResource
    • updateResource
    • listResource
    • removeResource

The off-the-cuff recommendation is to make the methods you don't want in the public API private in your class.

like image 155
Dan Holevoet Avatar answered Jan 22 '26 09:01

Dan Holevoet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!