Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop 2.0 - support binary input and output #1166

Closed
wants to merge 9 commits into from
Original file line number Diff line number Diff line change
Expand Up @@ -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"}}}"""
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)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package io.swagger.models.properties;

import io.swagger.models.Xml;

import java.util.*;

public class ByteArrayProperty extends AbstractProperty implements Property {


public ByteArrayProperty() {
super.type = "string";
super.format = "binary";
}

public static boolean isType(String type, String format) {
if("string".equals(type) && "binary".equals(format))
return true;
else return false;
}
public ByteArrayProperty xml(Xml xml) {
this.setXml(xml);
return this;
}

public ByteArrayProperty example(String example) {
this.setExample(example);
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,17 @@ public Model toModel(Property property) {
}

},
BYTE_ARRAY(ByteArrayProperty.class) {
@Override
protected boolean isType(String type, String format) {
return ByteArrayProperty.isType(type, format);
}

@Override
protected ByteArrayProperty create() {
return new ByteArrayProperty();
}
},
DATE(DateProperty.class) {
@Override
protected boolean isType(String type, String format) {
Expand Down