-
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.
ref #2992 - add support for LocalTime and custom system and primitive…
… types
- Loading branch information
Showing
4 changed files
with
261 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
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
91 changes: 91 additions & 0 deletions
91
modules/swagger-core/src/test/java/io/swagger/v3/core/resolving/Ticket2992Test.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,91 @@ | ||
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.TestObject2992; | ||
import io.swagger.v3.core.util.PrimitiveType; | ||
import io.swagger.v3.oas.models.media.Schema; | ||
import org.testng.annotations.Test; | ||
|
||
public class Ticket2992Test extends SwaggerTestBase { | ||
|
||
@Test | ||
public void testLocalTime() throws Exception { | ||
|
||
final ModelResolver modelResolver = new ModelResolver(mapper()); | ||
|
||
ModelConverterContextImpl context = new ModelConverterContextImpl(modelResolver); | ||
|
||
Schema model = context | ||
.resolve(new AnnotatedType(TestObject2992.class)); | ||
|
||
SerializationMatchers.assertEqualsToYaml(context.getDefinedModels(), "LocalTime:\n" + | ||
" type: object\n" + | ||
" properties:\n" + | ||
" hour:\n" + | ||
" type: integer\n" + | ||
" format: int32\n" + | ||
" minute:\n" + | ||
" type: integer\n" + | ||
" format: int32\n" + | ||
" second:\n" + | ||
" type: integer\n" + | ||
" format: int32\n" + | ||
" nano:\n" + | ||
" type: integer\n" + | ||
" format: int32\n" + | ||
"TestObject2992:\n" + | ||
" type: object\n" + | ||
" properties:\n" + | ||
" name:\n" + | ||
" type: string\n" + | ||
" a:\n" + | ||
" $ref: '#/components/schemas/LocalTime'\n" + | ||
" b:\n" + | ||
" $ref: '#/components/schemas/LocalTime'\n" + | ||
" c:\n" + | ||
" $ref: '#/components/schemas/LocalTime'\n" + | ||
" d:\n" + | ||
" type: string\n" + | ||
" format: date-time\n" + | ||
" e:\n" + | ||
" type: string\n" + | ||
" format: date-time\n" + | ||
" f:\n" + | ||
" type: string\n" + | ||
" format: date-time"); | ||
|
||
PrimitiveType.enablePartialTime(); | ||
context = new ModelConverterContextImpl(modelResolver); | ||
|
||
context | ||
.resolve(new AnnotatedType(TestObject2992.class)); | ||
|
||
SerializationMatchers.assertEqualsToYaml(context.getDefinedModels(), "TestObject2992:\n" + | ||
" type: object\n" + | ||
" properties:\n" + | ||
" name:\n" + | ||
" type: string\n" + | ||
" a:\n" + | ||
" type: string\n" + | ||
" format: partial-time\n" + | ||
" b:\n" + | ||
" type: string\n" + | ||
" format: partial-time\n" + | ||
" c:\n" + | ||
" type: string\n" + | ||
" format: partial-time\n" + | ||
" d:\n" + | ||
" type: string\n" + | ||
" format: date-time\n" + | ||
" e:\n" + | ||
" type: string\n" + | ||
" format: date-time\n" + | ||
" f:\n" + | ||
" type: string\n" + | ||
" format: date-time"); | ||
} | ||
|
||
} |
73 changes: 73 additions & 0 deletions
73
...les/swagger-core/src/test/java/io/swagger/v3/core/resolving/resources/TestObject2992.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,73 @@ | ||
package io.swagger.v3.core.resolving.resources; | ||
|
||
import java.time.LocalDateTime; | ||
import java.time.LocalTime; | ||
|
||
public class TestObject2992 { | ||
|
||
private String name; | ||
private LocalTime a; | ||
private LocalTime b; | ||
private LocalTime c; | ||
|
||
private LocalDateTime d; | ||
private LocalDateTime e; | ||
private LocalDateTime f; | ||
|
||
|
||
public LocalTime getA() { | ||
return a; | ||
} | ||
|
||
public void setA(LocalTime a) { | ||
this.a = a; | ||
} | ||
|
||
public LocalTime getB() { | ||
return b; | ||
} | ||
|
||
public void setB(LocalTime b) { | ||
this.b = b; | ||
} | ||
|
||
public LocalTime getC() { | ||
return c; | ||
} | ||
|
||
public void setC(LocalTime c) { | ||
this.c = c; | ||
} | ||
|
||
public LocalDateTime getD() { | ||
return d; | ||
} | ||
|
||
public void setD(LocalDateTime d) { | ||
this.d = d; | ||
} | ||
|
||
public LocalDateTime getE() { | ||
return e; | ||
} | ||
|
||
public void setE(LocalDateTime e) { | ||
this.e = e; | ||
} | ||
|
||
public LocalDateTime getF() { | ||
return f; | ||
} | ||
|
||
public void setF(LocalDateTime f) { | ||
this.f = f; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
} |