Skip to content

Commit

Permalink
Workaround mentioned in ryankennedy#67
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Janes committed Apr 25, 2014
1 parent 929f07b commit 8bd18d3
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 9 deletions.
2 changes: 1 addition & 1 deletion jaxrs-doclet-sample-dropwizard/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>jaxrs-doclet-parent</artifactId>
<groupId>com.hypnoticocelot</groupId>
<version>0.0.2</version>
<version>0.0.2-EK3-1-SNAPSHOT</version>
</parent>

<artifactId>jaxrs-doclet-sample-dropwizard</artifactId>
Expand Down
8 changes: 7 additions & 1 deletion jaxrs-doclet/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>jaxrs-doclet-parent</artifactId>
<groupId>com.hypnoticocelot</groupId>
<version>0.0.2</version>
<version>0.0.2-EK3-1-SNAPSHOT</version>
</parent>

<artifactId>jaxrs-doclet</artifactId>
Expand Down Expand Up @@ -33,6 +33,12 @@
<version>1.17.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.3.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.hypnoticocelot.jaxrs.doclet.model.Model;
import com.hypnoticocelot.jaxrs.doclet.translator.Translator;
import com.sun.javadoc.*;
import com.sun.javadoc.AnnotationDesc.ElementValuePair;

import java.util.*;
import java.util.regex.Matcher;
Expand Down Expand Up @@ -38,6 +39,16 @@ public Method parse() {
if (httpMethod == null) {
return null;
}
boolean merge = false;
for (AnnotationDesc desc : methodDoc.annotations()) {
for (ElementValuePair value : desc.elementValues()) {
if (value.element().qualifiedName().equals("com.wordnik.swagger.annotations.ApiOperation.hidden") &&
value.value().value().equals(true)) {
merge = true;
return null;
}
}
}

String path = parentPath + firstNonNull(parsePath(methodDoc.annotations()), "");

Expand Down
8 changes: 8 additions & 0 deletions jaxrs-doclet/src/test/resources/fixtures/sample/Service.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package fixtures.sample;

import javax.ws.rs.*;
import com.wordnik.swagger.annotations.ApiOperation;

@Path("/foo")
public class Service {
Expand All @@ -18,6 +19,13 @@ public int createSpeech(String speech) {
return speech.hashCode();
}

@ApiOperation(value = "hidden", hidden = true)
@POST
@Consumes("text/plain")
public String duplicatedPathAndMethod(String input) {
return input;
}

@Path("/annotated")
@POST
public int createSpeechWithAnnotatedPayload(@Deprecated String speech) {
Expand Down
12 changes: 6 additions & 6 deletions jaxrs-doclet/src/test/resources/fixtures/sample/foo.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
"dataType": "string"
}
],
"errorResponses": [
{
"code": 404,
"reason": "not found"
}
]
"errorResponses": [
{
"code": 404,
"reason": "not found"
}
]
},
{
"httpMethod": "POST",
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>com.hypnoticocelot</groupId>
<artifactId>jaxrs-doclet-parent</artifactId>
<packaging>pom</packaging>
<version>0.0.2</version>
<version>0.0.2-EK3-1-SNAPSHOT</version>
<name>JAX-RS Doclet</name>
<url>https://github.com/ryankennedy/swagger-jaxrs-doclet</url>
<description>
Expand Down

0 comments on commit 8bd18d3

Please sign in to comment.