-
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: refs #4290 - fixes anyof for non objects
- Loading branch information
Showing
3 changed files
with
50 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
33 changes: 33 additions & 0 deletions
33
modules/swagger-core/src/test/java/io/swagger/v3/core/resolving/Ticket4290Test.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,33 @@ | ||
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.Issue4290; | ||
import io.swagger.v3.oas.models.media.Schema; | ||
import org.testng.annotations.Test; | ||
|
||
public class Ticket4290Test extends SwaggerTestBase { | ||
@Test | ||
public void testAnyOf() throws Exception { | ||
final ModelResolver modelResolver = new ModelResolver(mapper()); | ||
|
||
final ModelConverterContextImpl context = new ModelConverterContextImpl(modelResolver); | ||
|
||
final Schema model = context | ||
.resolve(new AnnotatedType(Issue4290.class)); | ||
|
||
SerializationMatchers.assertEqualsToYaml(context.getDefinedModels(), "Issue4290:\n" + | ||
" type: object\n" + | ||
" properties:\n" + | ||
" value:\n" + | ||
" type: object\n" + | ||
" description: \"A string, a number or a boolean\"\n" + | ||
" anyOf:\n" + | ||
" - type: string\n" + | ||
" - type: number\n" + | ||
" - type: boolean"); | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
modules/swagger-core/src/test/java/io/swagger/v3/core/resolving/resources/Issue4290.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,9 @@ | ||
package io.swagger.v3.core.resolving.resources; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
public class Issue4290 { | ||
@Schema(description = "A string, a number or a boolean", anyOf = { String.class, Number.class, Boolean.class }) | ||
public Object value; | ||
|
||
} |