Ejemplo n.º 1
0
  /**
   * Gets the error documentation for the resource method annotation.
   *
   * @param resourceMethod Endpoint method to document.
   * @return a list of ResponseErrors in the parameter
   */
  List<ResponseError> getResponseErrors(ResourceMethod resourceMethod) {
    if (null == resourceMethod) return Collections.emptyList();

    final Collection<ResponseError> errors =
        Collections2.transform(
            Arrays.asList(resourceMethod.errors()),
            new Function<MethodError, ResponseError>() {
              @Override
              public ResponseError apply(MethodError from) {
                return new ResponseError(from.status().getStatusCode(), from.cause());
              }
            });

    return ImmutableList.copyOf(errors);
  }
Ejemplo n.º 2
0
  List<ApiExampleDocument> getExampleDocuments(ResourceMethod method) {
    if (null == method) return Collections.emptyList();

    final Collection<ApiExampleDocument> documents =
        Collections2.transform(
            Arrays.asList(method.examples()),
            new Function<ApiCallExample, ApiExampleDocument>() {
              @Override
              public ApiExampleDocument apply(ApiCallExample apiCallExample) {
                return new ApiExampleDocument(
                    apiCallExample.title(),
                    apiCallExample.description(),
                    apiCallExample.input(),
                    apiCallExample.contentType(),
                    apiCallExample.output(),
                    apiCallExample.accepts());
              }
            });

    return ImmutableList.copyOf(documents);
  }