diff --git a/modules/swagger-core/src/main/scala/com/wordnik/swagger/core/util/ReaderUtil.scala b/modules/swagger-core/src/main/scala/com/wordnik/swagger/core/util/ReaderUtil.scala index 6ef73cc77f..442e3a7df0 100644 --- a/modules/swagger-core/src/main/scala/com/wordnik/swagger/core/util/ReaderUtil.scala +++ b/modules/swagger-core/src/main/scala/com/wordnik/swagger/core/util/ReaderUtil.scala @@ -23,7 +23,7 @@ trait ReaderUtil { val tuples = listings.map(m => (m.resourcePath, m)) val grouped = tuples.groupBy(_._1) (for (group <- grouped) yield { - val apiDescriptions = (for(g <- group._2; api <- g._2.apis) yield api).toList + val apiDescriptions = (for(g <- group._2; api <- g._2.apis) yield api).filter(_.hidden == false).toList val models = (for(g <- group._2; models <- g._2.models) yield models).flatten.toMap group._2(0)._2.copy(apis = apiDescriptions, models = Option(models)) }).toList diff --git a/modules/swagger-core/src/main/scala/com/wordnik/swagger/model/SwaggerModels.scala b/modules/swagger-core/src/main/scala/com/wordnik/swagger/model/SwaggerModels.scala index 7496a34f22..cd5e80edd2 100644 --- a/modules/swagger-core/src/main/scala/com/wordnik/swagger/model/SwaggerModels.scala +++ b/modules/swagger-core/src/main/scala/com/wordnik/swagger/model/SwaggerModels.scala @@ -85,7 +85,8 @@ case class ApiListing ( case class ApiDescription ( path: String, description: Option[String], - operations: List[Operation] = List()) + operations: List[Operation] = List(), + hidden: Boolean = false) case class Operation ( method: String, diff --git a/modules/swagger-jaxrs/src/main/scala/com/wordnik/swagger/jaxrs/reader/BasicJaxrsReader.scala b/modules/swagger-jaxrs/src/main/scala/com/wordnik/swagger/jaxrs/reader/BasicJaxrsReader.scala index 2100cca963..4b7f444c86 100644 --- a/modules/swagger-jaxrs/src/main/scala/com/wordnik/swagger/jaxrs/reader/BasicJaxrsReader.scala +++ b/modules/swagger-jaxrs/src/main/scala/com/wordnik/swagger/jaxrs/reader/BasicJaxrsReader.scala @@ -27,9 +27,13 @@ class BasicJaxrsReader extends JaxrsApiReader { parentMethods: ListBuffer[Method]): Option[ApiListing] = { val api = cls.getAnnotation(classOf[Api]) val pathAnnotation = cls.getAnnotation(classOf[Path]) + var hidden = false val r = Option(api) match { - case Some(api) => api.value + case Some(api) => { + hidden = api.hidden + api.value + } case None => Option(pathAnnotation) match { case Some(p) => p.value case None => null @@ -108,7 +112,8 @@ class BasicJaxrsReader extends JaxrsApiReader { ApiDescription( addLeadingSlash(endpoint), None, - orderedOperations.toList) + orderedOperations.toList, + hidden) }).toList val models = ModelUtil.modelsFromApis(apis) Some(ApiListing ( diff --git a/modules/swagger-jaxrs/src/main/scala/com/wordnik/swagger/jaxrs/reader/DefaultJaxrsReader.scala b/modules/swagger-jaxrs/src/main/scala/com/wordnik/swagger/jaxrs/reader/DefaultJaxrsReader.scala index 188da68b68..571bc04a25 100644 --- a/modules/swagger-jaxrs/src/main/scala/com/wordnik/swagger/jaxrs/reader/DefaultJaxrsReader.scala +++ b/modules/swagger-jaxrs/src/main/scala/com/wordnik/swagger/jaxrs/reader/DefaultJaxrsReader.scala @@ -90,7 +90,8 @@ class DefaultJaxrsApiReader extends JaxrsApiReader { ApiDescription( addLeadingSlash(endpoint), None, - orderedOperations.toList) + orderedOperations.toList, + hidden = api.hidden) }).toList val basePath = { diff --git a/modules/swagger-jersey-jaxrs/src/main/scala/com/wordnik/swagger/jersey/JerseyApiReader.scala b/modules/swagger-jersey-jaxrs/src/main/scala/com/wordnik/swagger/jersey/JerseyApiReader.scala index d00a7f79a1..74844dd744 100644 --- a/modules/swagger-jersey-jaxrs/src/main/scala/com/wordnik/swagger/jersey/JerseyApiReader.scala +++ b/modules/swagger-jersey-jaxrs/src/main/scala/com/wordnik/swagger/jersey/JerseyApiReader.scala @@ -116,7 +116,8 @@ class JerseyApiReader extends JaxrsApiReader { ApiDescription( addLeadingSlash(endpoint), None, - orderedOperations.toList) + orderedOperations.toList, + api.hidden) }).toList val models = ModelUtil.modelsFromApis(apis) val basePath = { diff --git a/modules/swagger-jersey2-jaxrs/src/main/scala/com/wordnik/swagger/jersey/JerseyApiReader.scala b/modules/swagger-jersey2-jaxrs/src/main/scala/com/wordnik/swagger/jersey/JerseyApiReader.scala index 1b79b8ba93..d35b8592be 100644 --- a/modules/swagger-jersey2-jaxrs/src/main/scala/com/wordnik/swagger/jersey/JerseyApiReader.scala +++ b/modules/swagger-jersey2-jaxrs/src/main/scala/com/wordnik/swagger/jersey/JerseyApiReader.scala @@ -116,7 +116,8 @@ class JerseyApiReader extends JaxrsApiReader { ApiDescription( addLeadingSlash(endpoint), None, - orderedOperations.toList) + orderedOperations.toList, + api.hidden) }).toList val models = ModelUtil.modelsFromApis(apis) val basePath = { diff --git a/samples/java-jaxrs-subresource/src/main/java/com/wordnik/swagger/sample/resource/OwnerResource.java b/samples/java-jaxrs-subresource/src/main/java/com/wordnik/swagger/sample/resource/OwnerResource.java index d834302c3b..5091429025 100644 --- a/samples/java-jaxrs-subresource/src/main/java/com/wordnik/swagger/sample/resource/OwnerResource.java +++ b/samples/java-jaxrs-subresource/src/main/java/com/wordnik/swagger/sample/resource/OwnerResource.java @@ -24,7 +24,7 @@ import javax.ws.rs.*; @Path("/owner") -@Api(value = "/owner", description = "Operations about the owners", position = 1) +@Api(hidden = true, value = "/owner", description = "Operations about the owners", position = 1) @Produces("application/json") public class OwnerResource { private String petId; diff --git a/samples/java-jaxrs-subresource/src/test/scala/ResourceListingIT.scala b/samples/java-jaxrs-subresource/src/test/scala/ResourceListingIT.scala deleted file mode 100644 index 191c2f4dbd..0000000000 --- a/samples/java-jaxrs-subresource/src/test/scala/ResourceListingIT.scala +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright 2013 Wordnik, Inc. - * - * 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/LICENSE-2.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.wordnik.test.swagger.integration - -import com.wordnik.swagger.model._ - -import com.wordnik.swagger.core.util._ - -import org.junit.runner.RunWith - -import org.scalatest.junit.JUnitRunner -import org.scalatest.FlatSpec -import org.scalatest.matchers.ShouldMatchers - -import scala.collection.JavaConversions._ - -import scala.io._ - -@RunWith(classOf[JUnitRunner]) -class ResourceListingIT extends FlatSpec with ShouldMatchers { - it should "read a resource listing" in { - val json = Source.fromURL("http://localhost:8002/api/api-docs").mkString - val doc = ScalaJsonUtil.mapper.readValue(json, classOf[ResourceListing]) - - assert(doc.apis.size === 2) - assert((doc.apis.map(api => api.path).toSet & Set("/pet", "/owner")).size == 2) - } -}