Skip to content

Commit

Permalink
added example and trueType
Browse files Browse the repository at this point in the history
  • Loading branch information
clatko committed Oct 30, 2014
1 parent 9cf2814 commit ce72413
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 5 deletions.
Expand Up @@ -33,6 +33,8 @@
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface Api {
String apiVersion() default "";

/**
* The 'path' that is going to be used to host the API Declaration of the
* resource.
Expand Down Expand Up @@ -116,4 +118,5 @@
* @since 1.3.8
*/
boolean hidden() default false;

}
Expand Up @@ -107,4 +107,5 @@
* Valid values are {@code path}, {@code query}, {@code body}, {@code header} or {@code form}.
*/
String paramType() default "";
String trueType() default "";
}
Expand Up @@ -42,6 +42,7 @@
* A verbose description of the operation.
*/
String notes() default "";
String example() default "";

/**
* The response type of the operation.
Expand Down
Expand Up @@ -37,6 +37,7 @@
* as the path section they represent.
*/
String name() default "";
String trueType() default "";

/**
* A brief description of the parameter.
Expand Down
Expand Up @@ -92,6 +92,7 @@ case class Operation (
method: String,
summary: String,
notes: String,
example: String,
responseClass: String,
nickname: String,
position: Int,
Expand All @@ -112,6 +113,7 @@ case class Parameter (
dataType: String,
allowableValues: AllowableValues = AnyAllowableValues,
paramType: String,
trueType: String,
paramAccess: Option[String] = None)

case class ResponseMessage (
Expand Down
Expand Up @@ -191,6 +191,7 @@ object SwaggerSerializers extends Serializers {
}),
(json \ "summary").extract[String],
(json \ "notes").extractOrElse(""),
(json \ "example").extract[String],
(json \ "responseClass").extractOrElse({
!!(json, OPERATION, "responseClass", "missing required field", ERROR)
""
Expand All @@ -217,6 +218,7 @@ object SwaggerSerializers extends Serializers {
("method" -> x.method) ~
("summary" -> x.summary) ~
("notes" -> x.notes) ~
("example" -> x.example) ~
output ~
("nickname" -> x.nickname) ~
("produces" -> {
Expand Down Expand Up @@ -387,6 +389,7 @@ object SwaggerSerializers extends Serializers {
!!(json, OPERATION_PARAM, "type", "missing required field", ERROR)
""
}),
(json \ "trueType").extract[String],
(json \ "paramAccess").extractOpt[String]
)
}, {
Expand All @@ -399,6 +402,7 @@ object SwaggerSerializers extends Serializers {
("required" -> x.required) ~
toJsonSchema("type", x.dataType) ~
("paramType" -> x.paramType) ~
("trueType" -> x.trueType) ~
("allowMultiple" -> x.allowMultiple) ~
("paramAccess" -> x.paramAccess)

Expand Down Expand Up @@ -472,7 +476,8 @@ trait Serializers {
(json \ "protocols").extractOrElse(List()),
authorizations,
(json \ "apis").extract[List[ApiDescription]],
(json \ "models").extractOpt[Map[String, Model]]
(json \ "models").extractOpt[Map[String, Model]],
(json \ "description").extractOpt[String]
)
}, {
case x: ApiListing =>
Expand Down Expand Up @@ -521,7 +526,8 @@ trait Serializers {
case Some(e: Map[String, Model]) if (e.size > 0) => Extraction.decompose(e)
case _ => JNothing
}
})
}) ~
("description" -> x.description)
}
))

Expand Down Expand Up @@ -707,6 +713,7 @@ trait Serializers {
}),
(json \ "summary").extract[String],
(json \ "notes").extractOrElse(""),
(json \ "example").extract[String],
(json \ "responseClass").extractOrElse({
!!(json, OPERATION, "responseClass", "missing required field", ERROR)
""
Expand All @@ -730,6 +737,7 @@ trait Serializers {
("method" -> x.method) ~
("summary" -> x.summary) ~
("notes" -> x.notes) ~
("example" -> x.example) ~
("responseClass" -> x.responseClass) ~
("nickname" -> x.nickname) ~
("produces" -> {
Expand Down Expand Up @@ -805,6 +813,7 @@ trait Serializers {
!!(json, OPERATION_PARAM, "paramType", "missing required field", ERROR)
""
}),
(json \ "trueType").extract[String],
(json \ "paramAccess").extractOpt[String]
)
}, {
Expand All @@ -825,6 +834,7 @@ trait Serializers {
}
}) ~
("paramType" -> x.paramType) ~
("trueType" -> x.trueType) ~
("paramAccess" -> x.paramAccess)
}
))
Expand Down
6 changes: 3 additions & 3 deletions modules/swagger-core/src/test/scala/filter/TestSpecs.scala
Expand Up @@ -18,8 +18,8 @@ object TestSpecs {
def ordered = {
val apis = List(
ApiDescription("/", None, List(
Operation("GET", "does something", "notes", "void", "getSomething", 2),
Operation("POST", "does something else", "notes", "void", "postSomething", 1)
Operation("GET", "does something", "notes", "example", "void", "getSomething", 2),
Operation("POST", "does something else", "notes", "example", "void", "postSomething", 1)
)
)
)
Expand All @@ -35,7 +35,7 @@ object TestSpecs {
def subTypes = {
val apis = List(
ApiDescription("/", None, List(
Operation("GET", "does something", "notes", "Animal", "getSomething", 2))
Operation("GET", "does something", "notes", "example", "Animal", "getSomething", 2))
)
)
val models = Some(ModelConverters.readAll(classOf[Animal]).map(m => m.name -> m).toMap)
Expand Down

0 comments on commit ce72413

Please sign in to comment.