From a18409eb69d9c69435bb2f0bbec7b2540b46616d Mon Sep 17 00:00:00 2001 From: b_sapir Date: Thu, 6 Aug 2015 17:50:59 +0300 Subject: [PATCH] Support binary input body params and binary response - use format "binary" in swagger file --- modules/swagger-core/src/test/scala/ModelSerializerTest.scala | 2 +- .../java/io/swagger/models/properties/ByteArrayProperty.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/swagger-core/src/test/scala/ModelSerializerTest.scala b/modules/swagger-core/src/test/scala/ModelSerializerTest.scala index 72f0cf68c4..aa98199ef6 100644 --- a/modules/swagger-core/src/test/scala/ModelSerializerTest.scala +++ b/modules/swagger-core/src/test/scala/ModelSerializerTest.scala @@ -29,7 +29,7 @@ class ModelSerializerTest extends FlatSpec with Matchers { } it should "deserialize a model" in { - val json = """{"required":["intValue"],"properties":{"dateValue":{"type":"string","format":"date"},"longValue":{"type":"integer","format":"int64"},"dateTimeValue":{"type":"string","format":"date-time"},"intValue":{"type":"integer","format":"int32"},"byteArrayValue":{"type":"string","format":"byte"}}}""" + val json = """{"required":["intValue"],"properties":{"dateValue":{"type":"string","format":"date"},"longValue":{"type":"integer","format":"int64"},"dateTimeValue":{"type":"string","format":"date-time"},"intValue":{"type":"integer","format":"int32"},"byteArrayValue":{"type":"string","format":"binary"}}}""" val p = m.readValue(json, classOf[Model]) m.writeValueAsString(p) should equal(json) diff --git a/modules/swagger-models/src/main/java/io/swagger/models/properties/ByteArrayProperty.java b/modules/swagger-models/src/main/java/io/swagger/models/properties/ByteArrayProperty.java index 3a86f66e00..5806081dc1 100644 --- a/modules/swagger-models/src/main/java/io/swagger/models/properties/ByteArrayProperty.java +++ b/modules/swagger-models/src/main/java/io/swagger/models/properties/ByteArrayProperty.java @@ -9,11 +9,11 @@ public class ByteArrayProperty extends AbstractProperty implements Property { public ByteArrayProperty() { super.type = "string"; - super.format = "byte"; + super.format = "binary"; } public static boolean isType(String type, String format) { - if("string".equals(type) && "byte".equals(format)) + if("string".equals(type) && "binary".equals(format)) return true; else return false; }