From 240727f6f0d4fbc06b144f229f2332db558c103a Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Sun, 1 Jul 2012 17:50:40 -0700 Subject: [PATCH] Mostly fix handling of implicit parameter dataTypes The spec and the Pets example state that dataType when applied to ApiParamsImplicit should cause the specified type to be emitted into the model portion of the documentation file. This wasn't happening previously. The oversight was that there was no code calling docParam.setValueTypeInternal and therefore when it came time to emit the models the parameter was ignored. This change handles dataType for implicit params very much like responseClass. This handles _most_ usecases, however, I wasn't sure how you wanted to handle the parameter analog of isResponseMultiValue. Would it be correct to check allowMultiple and treat it similarily (specifying in the docs that a List[FooObj] is expected). The reason the Pet example seemed to work, is that in the example PetController some other method was returning a Pet object, thus forcing the object into the emitted model section. However I discovered this bug because my usecase wasn't so lucky. ;-) Thanks for the great tool! --- .../scala/com/wordnik/swagger/core/ApiReader.scala | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/swagger-core/src/main/scala/com/wordnik/swagger/core/ApiReader.scala b/modules/swagger-core/src/main/scala/com/wordnik/swagger/core/ApiReader.scala index 4054ea5bb0..2839f8f0d0 100644 --- a/modules/swagger-core/src/main/scala/com/wordnik/swagger/core/ApiReader.scala +++ b/modules/swagger-core/src/main/scala/com/wordnik/swagger/core/ApiReader.scala @@ -141,7 +141,17 @@ trait ApiSpecParserTrait extends BaseApiParser { docParam.allowMultiple = p.allowMultiple docParam.paramAccess = readString(p.access) docParam.internalDescription = readString(p.internalDescription) - docParam.dataType = readString(p.dataType) + val dataType = readString(p.dataType) + docParam.setValueTypeInternal(dataType) + docParam.dataType = try { + val cls = SwaggerContext.loadClass(dataType) + val annotatedName = ApiPropertiesReader.readName(cls) + // FIXME - support List[] similar to isResponseMultiValue + annotatedName + } catch { + case e: ClassNotFoundException => + dataType + } docParam.paramType = readString(p.paramType) docParam.paramType = if (docParam.paramType == null) TYPE_QUERY else docParam.paramType