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

refs swagger-api/swagger-core#2312 - cleanup #2364

Merged
merged 1 commit into from
Aug 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

// TODO #2312
public abstract class AbstractModelConverter implements ModelConverter {
protected final ObjectMapper _mapper;
protected final AnnotationIntrospector _intr;
Expand All @@ -43,19 +42,7 @@ public void setupModule(SetupContext context) {
_intr = mapper.getSerializationConfig().getAnnotationIntrospector();

}
/*
@Override
public Property resolve(Type type,
ModelConverterContext context,
Annotation[] annotations,
Iterator<ModelConverter> chain) {
if (chain.hasNext()) {
return chain.next().resolveProperty(type, context, annotations, chain);
} else {
return null;
}
}
*/

protected String _description(Annotated ann) {
// while name suggests it's only for properties, should work for any Annotated thing.
// also; with Swagger introspector's help, should get it from ApiModel/ApiModelProperty
Expand Down Expand Up @@ -135,12 +122,11 @@ protected String _findExampleValue(Annotated a) {
}

protected Boolean _findReadOnly(Annotated a) {
/*
ApiModelProperty prop = a.getAnnotation(ApiModelProperty.class);
if (prop != null) {
return prop.readOnly();
io.swagger.oas.annotations.media.Schema schema = a.getAnnotation(io.swagger.oas.annotations.media.Schema.class);
// TODO possibly set schema.readOnly to be Boolean object
if (schema != null && schema.readOnly()) {
return schema.readOnly();
}
*/
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -560,8 +560,6 @@ else if(PrimitiveType.fromType(type) != null) {
}
}

// Collections.sort(props, getPropertyComparator());

if(modelProps.size() > 0) {
model.setProperties(modelProps);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,38 +203,76 @@ public static Schema fillSchema(Schema schema, Type type) {
return schema;
}

// TODO! #2312 complete merge
public static Schema merge(Schema from, Schema to) {
if (from == null) {
return to;
}
if (to.getPattern() == null) {
to.setPattern(from.getPattern());
if (to.getDefault() == null) {
to.setDefault(from.getDefault());
}
if (to.getFormat() == null) {
to.setFormat(from.getFormat());
if (to.getDeprecated() == null) {
to.setDeprecated(from.getDeprecated());
}
if (to.getDescription() == null) {
to.setDescription(from.getDescription());
}
if (to.getDefault() == null) {
to.setDefault(from.getDefault());
}
if (to.getEnum() == null) {
to.setEnum(from.getEnum());
}
if (to.getExclusiveMinimum() == null) {
to.setExclusiveMinimum(from.getExclusiveMinimum());
if (to.getExample() == null) {
to.setExample(from.getExample());
}
if (to.getExclusiveMaximum() == null) {
to.setExclusiveMaximum(from.getExclusiveMaximum());
}
if (to.getMinimum() == null) {
to.setMinimum(from.getMinimum());
if (to.getExclusiveMinimum() == null) {
to.setExclusiveMinimum(from.getExclusiveMinimum());
}
if (to.getExtensions() == null) {
to.setExtensions(from.getExtensions());
}
if (to.getExternalDocs() == null) {
to.setExternalDocs(from.getExternalDocs());
}
if (to.getFormat() == null) {
to.setFormat(from.getFormat());
}
if (to.getMaximum() == null) {
to.setMaximum(from.getMaximum());
}
if (to.getMaxLength() == null) {
to.setMaxLength(from.getMaxLength());
}
if (to.getMinimum() == null) {
to.setMinimum(from.getMinimum());
}
if (to.getMinLength() == null) {
to.setMinLength(from.getMinLength());
}
if (to.getMultipleOf() == null) {
to.setMultipleOf(from.getMultipleOf());
}
if (to.getNullable() == null) {
to.setNullable(from.getNullable());
}
if (to.getPattern() == null) {
to.setPattern(from.getPattern());
}
if (to.getReadOnly() == null) {
to.setReadOnly(from.getReadOnly());
}
if (to.getRequired() == null) {
to.setRequired(from.getRequired());
}
if (to.getTitle() == null) {
to.setTitle(from.getTitle());
}
if (to.getXml() == null) {
to.setXml(from.getXml());
}
if (to.getWriteOnly() == null) {
to.setWriteOnly(from.getWriteOnly());
}
return to;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,27 +467,4 @@ public void setId(String id) {
}
*/

// TODO #2312 string arrays and maps impl and tests
/*
@Test(enabled = false, description = "shows how to model a string array schema")
public void testStringArraySchema() {

}
*/

@Schema(type = "string"/* container = "array" */)
static class stringArraySchema {}

@Test(enabled = false, description = "shows how to model a string map schema")
public void testStringMapSchema() {

}

@Schema(type = "string"/* container = "map" */)
static class stringMapSchema {}

static class JavaSucks {
@Schema(implementation = JavaSucks.class)
public Object values;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Manifest-Version: 1.0
Bnd-LastModified: 1502368884287
Bnd-LastModified: 1502449184030
Build-Jdk: 1.8.0_72
Built-By: frantuma
Bundle-Description: Sonatype helps open source projects to set up Maven
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,6 @@ private Operation parseMethod(Class<?> cls, Method method) {
// handle return type, add as response in case.
Type returnType = method.getGenericReturnType();
if (!shouldIgnoreClass(returnType.getTypeName())) {
//returnType.g
// TODO #2312 also add content to existing responses (from annotation) if it is not specified in annotation
Map<String, Schema> schemaMap = ModelConverters.getInstance().read(returnType);
if (schemaMap != null && !schemaMap.values().isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public void testSimpleCallback() {
" schema:\n" +
" type: string\n" +
" description: the URL to call with response data\n" +
" readOnly: true\n" +
" responses:\n" +
" default:\n" +
" description: no description\n" +
Expand Down