wordnik/swagger-core — pull request #586 by vandeti (2014-06-03 12:12:52+00:00)
Title: Test and suggested fix for issue 433

Hi,

When overriding models, complex properties are not expanded (not leading to $ref) when supplying the model json string and specifying "type" and "qualifiedType". I use this method because using the swagger api or scala collections from java can be quite awkward.

failing test before fix:
```
val converter = new OverrideConverter()
converter.add(classOf[Parent].getName(), """{"id":"Parent","properties":{"overriddenName":{"type":"string","qualifiedType":"java.lang.String"},"parentName":{"type":"string","qualifiedType":"java.lang.String"},"child":{"type":"Child","qualifiedType":"converter.models.Child"}}}""")
ModelConverters.addConverter(converter, true)
val a = ModelConverters.readAll(classOf[Parent])
println(JsonSerializer.asJson(a))
JsonSerializer.asJson(a) should be("""[{"id":"Parent","properties":{"overriddenName":{"type":"string"},"parentName":{"type":"string"},"child":{"$ref":"Child"}}},{"id":"Child","properties":{"childName":{"type":"string"}}}]""")
```

following test shows you can make it work when you use the api to construct the overridden Model:
```
val converter = new OverrideConverter()
val props = new LinkedHashMap[String, ModelProperty]
props += "overriddenName" -> ModelProperty(
"string",
"java.lang.String")

props += "parentName" -> ModelProperty(
"string",
"java.lang.String")

props += "child" -> ModelProperty(
"Child",
"converter.models.Child")

var model = Model("Parent",
"Parent",
classOf[Parent].getName(),
props)
converter.add(classOf[Parent].getName(), model);
ModelConverters.addConverter(converter, true)
val a = ModelConverters.readAll(classOf[Parent])
println(JsonSerializer.asJson(a))
JsonSerializer.asJson(a) should be("""[{"id":"Parent","properties":{"overriddenName":{"type":"string"},"parentName":{"type":"string"},"child":{"$ref":"Child"}}},{"id":"Child","properties":{"childName":{"type":"string"}}}]""")
```

This pointed me to the JsonSchemaModelPropertySerializer where the qualifiedType was skipped. Once the qualifiedType is parsed and added to the Model my test which supplies the json string works.

Kr,

Tim