use of io.swagger.v3.core.converter.AnnotatedType in project swagger-core by swagger-api.
the class SimpleGenerationTest method testSimple.
@Test
public void testSimple() throws Exception {
final Schema model = context.resolve(new AnnotatedType(SimpleBean.class));
assertNotNull(model);
assertEquals(model.getDescription(), "DESC");
final Map<String, Schema> props = model.getProperties();
assertEquals(props.size(), 6);
for (Map.Entry<String, Schema> entry : props.entrySet()) {
final String name = entry.getKey();
final Schema prop = entry.getValue();
if ("a".equals(name)) {
assertEquals(prop.getType(), "string");
} else if ("b".equals(name)) {
assertEquals(prop.getType(), "integer");
assertEquals(prop.getFormat(), "int32");
} else if ("c".equals(name)) {
assertEquals(prop.getType(), "integer");
assertEquals(prop.getFormat(), "int64");
} else if ("d".equals(name)) {
assertEquals(prop.getType(), "number");
assertEquals(prop.getFormat(), "float");
} else if ("e".equals(name)) {
assertEquals(prop.getType(), "number");
assertEquals(prop.getFormat(), "double");
} else if ("f".equals(name)) {
assertEquals(prop.getType(), "string");
assertEquals(prop.getFormat(), "date-time");
} else {
fail(String.format("Unknown property '%s'", name));
}
}
}
use of io.swagger.v3.core.converter.AnnotatedType in project swagger-core by swagger-api.
the class SimpleGenerationTest method testStringDateMap.
@Test
public void testStringDateMap() throws Exception {
final Schema model = context.resolve(new AnnotatedType(StringDateMapBean.class));
final Map<String, Schema> props = model.getProperties();
assertEquals(props.size(), 1);
String key = props.keySet().iterator().next();
final Schema prop = props.get(key);
assertEquals(key, "stuff");
}
use of io.swagger.v3.core.converter.AnnotatedType in project swagger-core by swagger-api.
the class SimpleGenerationTest method testOrdering.
@Test
public void testOrdering() throws Exception {
final Schema jsonOrderBean = context.resolve(new AnnotatedType(JsonOrderBean.class));
final Map<String, Schema> props = jsonOrderBean.getProperties();
assertEquals(new ArrayList<String>(props.keySet()), Arrays.asList("a", "b", "c", "d"));
}
use of io.swagger.v3.core.converter.AnnotatedType in project swagger-core by swagger-api.
the class Ticket2189Test method testTicket2189.
@Test
public void testTicket2189() {
final Schema model = context.resolve(new AnnotatedType(BaseClass.class));
assertNotNull(model);
String yaml = "BaseClass:\n" + " type: object\n" + " properties:\n" + " property:\n" + " type: string\n" + " type:\n" + " type: string\n" + "SubClass:\n" + " type: object\n" + " allOf:\n" + " - $ref: '#/components/schemas/BaseClass'\n" + " - type: object\n" + " properties:\n" + " subClassProperty:\n" + " type: string";
SerializationMatchers.assertEqualsToYaml(context.getDefinedModels(), yaml);
}
use of io.swagger.v3.core.converter.AnnotatedType in project swagger-core by swagger-api.
the class Ticket2862SubtypeTest method testSubType.
@Test
public void testSubType() throws Exception {
final ModelResolver modelResolver = new ModelResolver(mapper());
final ModelConverterContextImpl context = new ModelConverterContextImpl(modelResolver);
final Schema model = context.resolve(new AnnotatedType(Ticket2862Model.class));
SerializationMatchers.assertEqualsToYaml(context.getDefinedModels(), "Ticket2862Model:\n" + " type: object\n" + " properties:\n" + " Ticket2862Model:\n" + " type: object\n" + "Ticket2862ModelImpl:\n" + " type: string\n" + " allOf:\n" + " - $ref: '#/components/schemas/Ticket2862Model'\n" + " enum:\n" + " - VALUE1\n" + " - VALUE2\n");
}
Aggregations