forked from swagger-api/swagger-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This I think is a fix for issue swagger-api#4059.
- Loading branch information
1 parent
02b1e77
commit 38c2672
Showing
2 changed files
with
100 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
modules/swagger-core/src/test/java/io/swagger/v3/core/resolving/Ticket4059Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package io.swagger.v3.core.resolving; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import com.fasterxml.jackson.annotation.JsonValue; | ||
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.oas.models.media.Schema; | ||
import org.testng.annotations.Test; | ||
|
||
public class Ticket4059Test extends SwaggerTestBase { | ||
|
||
@Test | ||
public void testJsonIgnoreAnnotation() throws Exception { | ||
|
||
final ModelResolver modelResolver = new ModelResolver(mapper()); | ||
|
||
ModelConverterContextImpl context = new ModelConverterContextImpl(modelResolver); | ||
|
||
Schema model = context | ||
.resolve(new AnnotatedType(ExtendedRequest.class)); | ||
|
||
SerializationMatchers.assertEqualsToYaml(context.getDefinedModels(), "ExtendedRequest:\n" + | ||
" type: object\n" + | ||
" properties:\n" + | ||
" id:\n" + | ||
" type: string\n" + | ||
" id2:\n" + | ||
" type: string"); | ||
|
||
} | ||
|
||
static class ExtendedRequest extends Request{ | ||
@JsonIgnore(value = false) // Don't ignore me | ||
private Id id; | ||
@JsonIgnore(value = true) | ||
private String fieldTwo; | ||
@JsonIgnore | ||
private String fieldThree; | ||
|
||
public String getFieldTwo() { | ||
return fieldTwo; | ||
} | ||
|
||
public void setFieldTwo(String fieldTwo) { | ||
this.fieldTwo = fieldTwo; | ||
} | ||
|
||
public String getFieldThree() { | ||
return fieldThree; | ||
} | ||
|
||
public void setFieldThree(String fieldThree) { | ||
this.fieldThree = fieldThree; | ||
} | ||
|
||
public Id getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Id id) { | ||
this.id = id; | ||
} | ||
} | ||
|
||
static class Request { | ||
@JsonIgnore | ||
private Id id; | ||
|
||
@JsonIgnore(value = false) // Don't ignore me | ||
private Id id2; | ||
|
||
public Id getId2() { | ||
return id2; | ||
} | ||
|
||
public void setId2(Id id2) { | ||
this.id2 = id2; | ||
} | ||
|
||
public Id getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Id id) { | ||
this.id = id; | ||
} | ||
} | ||
|
||
static class Id { | ||
private String value; | ||
|
||
@JsonValue | ||
public String getValue() { | ||
return value; | ||
} | ||
} | ||
} |