Skip to content

Commit

Permalink
Mostly fix handling of implicit parameter dataTypes
Browse files Browse the repository at this point in the history
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!
  • Loading branch information
Kevin Hester committed Jul 2, 2012
1 parent 10e0cb3 commit 240727f
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 240727f

Please sign in to comment.