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.
Fix for swagger-api#4362 - Resolving Schema for system enums fails if…
… enumsAsRef is enabled
- Loading branch information
Martin Dendis
authored and
Martin Dendis
committed
Feb 17, 2023
1 parent
0543bda
commit 953af3e
Showing
2 changed files
with
44 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
43 changes: 43 additions & 0 deletions
43
modules/swagger-core/src/test/java/io/swagger/v3/core/resolving/Ticket4362Test.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,43 @@ | ||
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.oas.models.media.Schema; | ||
import org.testng.annotations.AfterMethod; | ||
import org.testng.annotations.Test; | ||
|
||
import java.time.DayOfWeek; | ||
|
||
public class Ticket4362Test extends SwaggerTestBase { | ||
|
||
@AfterMethod | ||
public void afterTest() { | ||
ModelResolver.enumsAsRef = false; | ||
} | ||
|
||
@Test | ||
public void testAnyOf() throws Exception { | ||
ModelResolver.enumsAsRef = true; | ||
|
||
final ModelResolver modelResolver = new ModelResolver(mapper()); | ||
|
||
final ModelConverterContextImpl context = new ModelConverterContextImpl(modelResolver); | ||
|
||
final Schema model = context | ||
.resolve(new AnnotatedType(DayOfWeek.class)); | ||
|
||
SerializationMatchers.assertEqualsToYaml(context.getDefinedModels(), "DayOfWeek:\n" + | ||
" type: string\n" + | ||
" enum:\n" + | ||
" - MONDAY\n" + | ||
" - TUESDAY\n" + | ||
" - WEDNESDAY\n" + | ||
" - THURSDAY\n" + | ||
" - FRIDAY\n" + | ||
" - SATURDAY\n" + | ||
" - SUNDAY"); | ||
} | ||
|
||
} |