Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sdaschner committed Oct 13, 2018
2 parents 136f4be + 0e6a11d commit 4951355
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,17 @@ public void visit(FieldDeclaration field, Void arg) {
field.getComment()
.filter(Comment::isJavadocComment)
.map(this::toJavaDoc)
.ifPresent(c -> classComments.get(className).getFieldComments().add(createFieldComment(c, field)));
.ifPresent(c ->createFieldComment(c, field));
super.visit(field, arg);
}

private MemberParameterTag createFieldComment(Javadoc javadoc, FieldDeclaration field) {
return createMemberParamTag(javadoc.getDescription(), field.getAnnotations().stream());
private void createFieldComment(Javadoc javadoc, FieldDeclaration field) {
ClassComment classComment = classComments.get(className);
if(classComment == null) {
classComment = new ClassComment("", new HashMap<>(), false);
classComments.put(className, classComment);
}
classComment.getFieldComments().add(createMemberParamTag(javadoc.getDescription(), field.getAnnotations().stream()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ private static Resources getResources() {
ResourceMethod fourthGet = ResourceMethodBuilder.withMethod(HttpMethod.GET, "Returns a test string with plain text.").andAcceptMediaTypes("application/json")
.andResponseMediaTypes("text/plain", "application/json").andResponse(200, ResponseBuilder.withResponseBody(stringIdentifier).build()).build();
addMethods(resources, "test/test", fourthGet);

// resourceWithoutClassLevelJavadoc/test
ResourceMethod getResourceWithoutJavadoc = ResourceMethodBuilder.withMethod(HttpMethod.GET, "Returns a test string in json.").andAcceptMediaTypes("application/json")
.andResponseMediaTypes("application/json").andResponse(200, ResponseBuilder.withResponseBody(stringIdentifier).build()).build();
addMethods(resources, "resourceWithoutJavadoc/test", getResourceWithoutJavadoc);

// complex
ResourceMethod eighthGet = ResourceMethodBuilder.withMethod(HttpMethod.GET).andResponseMediaTypes("application/json")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (C) 2015 Sebastian Daschner, sebastian-daschner.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sebastian_daschner.jaxrs_test;

import javax.ejb.Stateless;
import javax.inject.Inject;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

@Stateless
@Path("resourceWithoutJavadoc")
public class ResourceWithoutClassLevelJavadoc {

/**
* Simple field comment (see issue #178)
*/
@Inject
Manager<Integer> manager;

/**
* Returns a test string in json.
*
* @return Ignore this comment
*/
@GET
@Path("test")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response testJson() {
return Response.ok("{\"hi\":\"hello\"}", MediaType.APPLICATION_JSON).build();
}

}

0 comments on commit 4951355

Please sign in to comment.