-
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.
Merge pull request #4720 from swagger-api/Issue-4679-OAS31-schema-imp…
- Loading branch information
Showing
2 changed files
with
58 additions
and
0 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
55 changes: 55 additions & 0 deletions
55
modules/swagger-core/src/test/java/io/swagger/v3/core/resolving/Ticket4679Test.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,55 @@ | ||
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.util.Yaml; | ||
import io.swagger.v3.core.util.Yaml31; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import org.testng.annotations.Test; | ||
|
||
import java.util.Map; | ||
|
||
public class Ticket4679Test extends SwaggerTestBase{ | ||
|
||
@Test(description = "Custom schema implementation in property overrides type value") | ||
public void testCustomSchemaImplementation() { | ||
|
||
String expectedYaml = "ModelWithCustomSchemaImplementationInProperty:\n" + | ||
" properties:\n" + | ||
" exampleField:\n" + | ||
" type: integer\n" + | ||
" format: int32\n" + | ||
" secondExampleField:\n" + | ||
" type: string\n"; | ||
|
||
Map<String, io.swagger.v3.oas.models.media.Schema> stringSchemaMap = ModelConverters.getInstance(true).readAll(ModelWithCustomSchemaImplementationInProperty.class); | ||
SerializationMatchers.assertEqualsToYaml31(stringSchemaMap, expectedYaml); | ||
} | ||
|
||
static class ModelWithCustomSchemaImplementationInProperty { | ||
|
||
@Schema(implementation = Integer.class) | ||
private String exampleField; | ||
|
||
@Schema(type = "string") | ||
private Integer secondExampleField; | ||
|
||
public String getExampleField() { | ||
return exampleField; | ||
} | ||
|
||
public void setExampleField(String exampleField) { | ||
this.exampleField = exampleField; | ||
} | ||
|
||
public Integer getSecondExampleField() { | ||
return secondExampleField; | ||
} | ||
|
||
public void setSecondExampleField(Integer secondExampleField) { | ||
this.secondExampleField = secondExampleField; | ||
} | ||
|
||
|
||
} | ||
} |