-
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.
refs #3904 - annotations support for @JsonValue types
- Loading branch information
Showing
4 changed files
with
55 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
52 changes: 52 additions & 0 deletions
52
modules/swagger-core/src/test/java/io/swagger/v3/core/resolving/Ticket3904Test.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,52 @@ | ||
package io.swagger.v3.core.resolving; | ||
|
||
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 Ticket3904Test extends SwaggerTestBase { | ||
|
||
@Test | ||
public void testJsonValueSchemaAnnotation() throws Exception { | ||
|
||
final ModelResolver modelResolver = new ModelResolver(mapper()); | ||
|
||
ModelConverterContextImpl context = new ModelConverterContextImpl(modelResolver); | ||
|
||
Schema model = context | ||
.resolve(new AnnotatedType(Request.class)); | ||
|
||
SerializationMatchers.assertEqualsToYaml(context.getDefinedModels(), "Request:\n" + | ||
" type: object\n" + | ||
" properties:\n" + | ||
" id:\n" + | ||
" type: string\n" + | ||
" description: Description of ID."); | ||
|
||
} | ||
|
||
static class Request { | ||
@io.swagger.v3.oas.annotations.media.Schema(description = "Description of ID.") | ||
private Id id; | ||
|
||
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; | ||
} | ||
} | ||
} |
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
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