use of io.swagger.v3.oas.annotations.media.Schema in project swagger-core by swagger-api.
the class Ticket3904Test method testJsonValueSchemaAnnotation.
@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.");
}
use of io.swagger.v3.oas.annotations.media.Schema in project swagger-core by swagger-api.
the class RequiredFieldModelTest method testApiModelPropertySecondPosition.
@Test(description = "it should apply required flag when XmlElement annotation first")
public void testApiModelPropertySecondPosition() {
final Map<String, Schema> models = ModelConverters.getInstance().readAll(XmlFirstRequiredFieldModel.class);
final Schema model = models.get("aaa");
final Schema prop = (Schema) model.getProperties().get("a");
assertNotNull(prop);
assertTrue(model.getRequired().contains("a"));
}
use of io.swagger.v3.oas.annotations.media.Schema in project swagger-core by swagger-api.
the class RequiredFieldModelTest method testApiModelPropertyFirstPosition.
@Test(description = "it should apply required flag when ApiProperty annotation first")
public void testApiModelPropertyFirstPosition() {
final Map<String, Schema> models = ModelConverters.getInstance().readAll(ApiFirstRequiredFieldModel.class);
final Schema model = models.get("aaa");
final Schema prop = (Schema) model.getProperties().get("bla");
assertNotNull(prop);
assertTrue(model.getRequired().contains("bla"));
}
use of io.swagger.v3.oas.annotations.media.Schema in project swagger-core by swagger-api.
the class ContainerTest method testMap.
@Test
public void testMap() throws Exception {
final ModelResolver modelResolver = new ModelResolver(mapper());
final ModelConverterContextImpl context = new ModelConverterContextImpl(modelResolver);
final Schema model = context.resolve(new AnnotatedType(MapBean.class));
final Map<String, Schema> props = model.getProperties();
assertEquals(1, props.size());
final Schema prop = props.get("stuff");
assertNotNull(prop);
assertEquals(prop.getType(), "object");
final Schema items = (Schema) prop.getAdditionalProperties();
assertNotNull(items);
assertEquals(items.getType(), "string");
assertEquals(items.getFormat(), "date-time");
}
use of io.swagger.v3.oas.annotations.media.Schema in project swagger-core by swagger-api.
the class HiddenFieldTest method testHiddenFieldInJsonCreator.
@Test(description = "it should ignore a hidden field in @JsonCreator")
public void testHiddenFieldInJsonCreator() {
final Map<String, Schema> models = ModelConverters.getInstance().read(ModelWithHiddenFieldsInJsonCreator.class);
final Schema model = models.get("ModelWithHiddenFieldsInJsonCreator");
assertNotNull(model);
assertEquals(model.getProperties().size(), 1);
final Schema idValue = (Schema) model.getProperties().get("id");
assertTrue(idValue instanceof IntegerSchema);
final Schema hiddenValue = (Schema) model.getProperties().get("hidden");
assertNull(hiddenValue);
}
Aggregations