cloudendpoints / endpoints-java

A Java framework for building RESTful APIs on Google App Engine
Apache License 2.0
32 stars 35 forks source link

Endpoints CLI Tool Error. #151

Closed cyraid closed 6 years ago

cyraid commented 6 years ago

Hi there,

When I ran the tool with:

endpoints-framework-tools get-openapi-doc --war="my/dir" --output="somedir/" com.SomeClass

It responds with:

Error: null

That's quite the error messages. :/ I've been struggling with this for awhile. It works when I generate with the "get-client-lib" though.. Here's what my SomeClass looks like:

@Api(
  name        = "somename",
  title       = "sometitle",
  version     = "v1",
  description = "somedesc",
  clientIds   = {
    Constant.API_EXPLORER_CLIENT_ID,
    Core.WEB_CLIENT_ID
  }, // clientIds //
  namespace   = @ApiNamespace(
    ownerDomain = Core.PROJECT_DOMAIN,
    ownerName   = Core.PROJECT_DOMAIN,
    packagePath = ""
  ), // namespace //
  issuers = {
    @ApiIssuer(
      name    = "firebase",
      issuer  = "https://securetoken.google.com/" + Core.PROJECT_ID,
      jwksUri = "https://www.googleapis.com/robot/v1/metadata/x509/securetoken@system.gserviceaccount.com"
    ) // ApiIssuer //
  } // issuers //
) // Api //

public class SomeClass {

  @ApiMethod(name = "users", httpMethod = ApiMethod.HttpMethod.GET)
  public ApiResult getUsers() {
    return ApiResult.ok("Yeah");
  } // Function //

  @ApiMethod(name = "subscribe", httpMethod = ApiMethod.HttpMethod.GET)
  public ApiResult subscribe(@Named("token") String token) {
    return ApiResult.ok("All good");
  } // Function //

} // Class //

Edit: Sorry I had a typo in the war directory in the get-discovery-doc, so I got that to work, but I double checked everything with the get-openapi-doc and it always responds with Error: null.

tangiel commented 6 years ago

I think we probably want to revert the logging to print the stack trace. I don't remember why we moved to change it to just print the exception message, but this isn't the first time it hasn't been a helpful message.

cyraid commented 6 years ago

Any idea why the get-openapi-doc isn't working by chance?

tangiel commented 6 years ago

I'm not certain. Are you using Maven or Gradle? You could use a build plugin instead. It might help.

cyraid commented 6 years ago

I'm using neither, just IntelliJ IDEA Ultimate. Would be nice to have it built into the editor. This is the reason I'm using the CLI (instead of maven/gradle).

cyraid commented 6 years ago

It turns out --output was a pointing to a directory and not a filename. It's my bad, I suppose this could be left open for the better errors? Seeing as output is used as a directory as one option and a file as another, perhaps detecting if it's a directory, to add openapi.json? Or just output an error saying "path needs to be a filename" or something?

tangiel commented 6 years ago

I added some more error checking as well as printing a full stack trace, rather than logging the exception message.