use of io.swagger.v3.core.converter.AnnotatedType in project swagger-core by swagger-api.
the class Ticket2992Test method testLocalTime.
@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");
}
use of io.swagger.v3.core.converter.AnnotatedType in project swagger-core by swagger-api.
the class Ticket2972Test method testLocalTime.
@Test
public void testLocalTime() throws Exception {
final ModelResolver modelResolver = new ModelResolver(mapper());
ModelConverterContextImpl context = new ModelConverterContextImpl(modelResolver);
Schema model = context.resolve(new AnnotatedType(TestObject2972.class));
SerializationMatchers.assertEqualsToYaml(context.getDefinedModels(), "TestObject2972:\n" + " type: object\n" + " properties:\n" + " myField1:\n" + " type: object\n" + " additionalProperties:\n" + " type: string\n" + " myField2:\n" + " type: object\n" + " additionalProperties:\n" + " type: string");
}
use of io.swagger.v3.core.converter.AnnotatedType in project swagger-core by swagger-api.
the class Ticket3197Test method testTicket3197.
@Test
public void testTicket3197() throws Exception {
final Schema model = context.resolve(new AnnotatedType(Car.class));
assertNotNull(model);
String yaml = "Car:\n" + " required:\n" + " - type\n" + " type: object\n" + " properties:\n" + " carMetaData:\n" + " type: string\n" + " type:\n" + " type: string\n" + " discriminator:\n" + " propertyName: type\n" + " mapping:\n" + " RaceCar: '#/components/schemas/RaceCar'\n" + " SportCar: '#/components/schemas/SportCar'\n" + " oneOf:\n" + " - $ref: '#/components/schemas/RaceCar'\n" + " - $ref: '#/components/schemas/SportCar'\n" + "RaceCar:\n" + " required:\n" + " - carMetaData\n" + " - id\n" + " type: object\n" + " allOf:\n" + " - $ref: '#/components/schemas/Car'\n" + " - type: object\n" + " properties:\n" + " id:\n" + " type: integer\n" + " format: int64\n" + " model:\n" + " type: string\n" + "SportCar:\n" + " required:\n" + " - id\n" + " type: object\n" + " allOf:\n" + " - $ref: '#/components/schemas/Car'\n" + " - type: object\n" + " properties:\n" + " id:\n" + " type: integer\n" + " format: int64\n" + " model:\n" + " type: string\n";
SerializationMatchers.assertEqualsToYaml(context.getDefinedModels(), yaml);
}
use of io.swagger.v3.core.converter.AnnotatedType in project swagger-core by swagger-api.
the class Ticket3365Test method testTicket3365.
@Test
public void testTicket3365() {
Schema model = context.resolve(new AnnotatedType(ExampleWithJson.class));
assertNotNull(model);
SerializationMatchers.assertEqualsToYaml(model, "required:\n" + "- param1\n" + "type: object\n" + "properties:\n" + " param1:\n" + " title: Cron formatted invoice schedule\n" + " type: object\n" + " example:\n" + " type: array\n" + " items:\n" + " type: string\n" + " format: byte");
model = context.resolve(new AnnotatedType(ExampleStartingWithInteger.class));
assertNotNull(model);
SerializationMatchers.assertEqualsToYaml(model, "required:\n" + "- param1\n" + "type: object\n" + "properties:\n" + " param1:\n" + " title: Cron formatted invoice schedule\n" + " type: string\n" + " example: 0 0 5 * *\n");
}
use of io.swagger.v3.core.converter.AnnotatedType in project swagger-core by swagger-api.
the class ContainerTest method testArray.
@Test
public void testArray() throws Exception {
final ModelResolver modelResolver = new ModelResolver(mapper());
final ModelConverterContextImpl context = new ModelConverterContextImpl(modelResolver);
final Schema model = context.resolve(new AnnotatedType(ArrayBean.class));
final Map<String, Schema> props = model.getProperties();
assertEquals(1, props.size());
final Schema prop = props.get("a");
assertNotNull(prop);
assertEquals(prop.getType(), "array");
final Schema items = ((ArraySchema) prop).getItems();
assertNotNull(items);
assertEquals(items.getType(), "integer");
}
Aggregations