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

ref #2972 - fixes resolving multiple map properties #3001

Merged
merged 1 commit into from
Nov 2, 2018
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 @@ -618,7 +618,7 @@ public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context

if (property != null) {
if (property.get$ref() == null) {
if (!"object".equals(property.getType())) {
if (!"object".equals(property.getType()) || (property instanceof MapSchema)) {
try {
String cloneName = property.getName();
property = Json.mapper().readValue(Json.pretty(property), Schema.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package io.swagger.v3.core.resolving;

import io.swagger.v3.core.converter.AnnotatedType;
import io.swagger.v3.core.converter.ModelConverterContextImpl;
import io.swagger.v3.core.jackson.ModelResolver;
import io.swagger.v3.core.matchers.SerializationMatchers;
import io.swagger.v3.core.resolving.resources.TestObject2972;
import io.swagger.v3.oas.models.media.Schema;
import org.testng.annotations.Test;

public class Ticket2972Test extends SwaggerTestBase {

@Test
public void testLocalTime() throws Exception {

final ModelResolver modelResolver = new ModelResolver(mapper());

ModelConverterContextImpl context = new ModelConverterContextImpl(modelResolver);

Schema model = context
.resolve(new AnnotatedType(TestObject2972.class));

SerializationMatchers.assertEqualsToYaml(context.getDefinedModels(), "TestObject2972:\n" +
" type: object\n" +
" properties:\n" +
" myField1:\n" +
" type: object\n" +
" additionalProperties:\n" +
" type: string\n" +
" myField2:\n" +
" type: object\n" +
" additionalProperties:\n" +
" type: string");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.swagger.v3.core.resolving.resources;

import java.util.Map;

public class TestObject2972 {

public Map<String, String> myField1;
public Map<String, String> myField2;
}