-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix @JsonUnwrapped does not copy required properties
- Loading branch information
Showing
4 changed files
with
78 additions
and
2 deletions.
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
36 changes: 36 additions & 0 deletions
36
...les/swagger-core/src/test/java/io/swagger/v3/core/resolving/JacksonJsonUnwrappedTest.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,36 @@ | ||
package io.swagger.v3.core.resolving; | ||
|
||
import io.swagger.v3.core.converter.ModelConverters; | ||
import io.swagger.v3.core.matchers.SerializationMatchers; | ||
import io.swagger.v3.core.resolving.resources.JacksonUnwrappedRequiredProperty; | ||
import org.testng.annotations.Test; | ||
|
||
public class JacksonJsonUnwrappedTest { | ||
|
||
@Test(description = "test the @JsonUnwrapped behaviour when required Properties") | ||
public void jacksonJsonUnwrappedTest() { | ||
|
||
SerializationMatchers | ||
.assertEqualsToYaml(ModelConverters.getInstance().read( | ||
JacksonUnwrappedRequiredProperty.class), "InnerTypeRequired:\n" + | ||
" required:\n" + | ||
" - name\n" + | ||
" type: object\n" + | ||
" properties:\n" + | ||
" foo:\n" + | ||
" type: integer\n" + | ||
" format: int32\n" + | ||
" name:\n" + | ||
" type: string\n" + | ||
"JacksonUnwrappedRequiredProperty:\n" + | ||
" required:\n" + | ||
" - name\n" + | ||
" type: object\n" + | ||
" properties:\n" + | ||
" foo:\n" + | ||
" type: integer\n" + | ||
" format: int32\n" + | ||
" name:\n" + | ||
" type: string\n"); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
.../swagger-core/src/test/java/io/swagger/v3/core/resolving/resources/InnerTypeRequired.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,17 @@ | ||
package io.swagger.v3.core.resolving.resources; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
public class InnerTypeRequired { | ||
public int foo; | ||
@Schema(required = true) | ||
public String name; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...rc/test/java/io/swagger/v3/core/resolving/resources/JacksonUnwrappedRequiredProperty.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,15 @@ | ||
package io.swagger.v3.core.resolving.resources; | ||
|
||
import com.fasterxml.jackson.annotation.JsonUnwrapped; | ||
|
||
public class JacksonUnwrappedRequiredProperty { | ||
@JsonUnwrapped private final InnerTypeRequired innerType; | ||
|
||
public JacksonUnwrappedRequiredProperty(InnerTypeRequired innerType) { | ||
this.innerType = innerType; | ||
} | ||
|
||
public InnerTypeRequired getInnerType() { | ||
return innerType; | ||
} | ||
} |