use of io.swagger.v3.core.converter.ModelConverterContextImpl in project swagger-core by swagger-api.
the class Ticket3197Test method beforeMethod.
@BeforeMethod
public void beforeMethod() {
ModelResolver.composedModelPropertiesAsSibling = false;
modelResolver = new ModelResolver(new ObjectMapper());
context = new ModelConverterContextImpl(modelResolver);
}
use of io.swagger.v3.core.converter.ModelConverterContextImpl in project swagger-core by swagger-api.
the class Ticket3197Test method testTicket3197AsSibling.
@Test
public void testTicket3197AsSibling() throws Exception {
ModelResolver.composedModelPropertiesAsSibling = true;
ModelResolver myModelResolver = new ModelResolver(new ObjectMapper());
ModelResolver.composedModelPropertiesAsSibling = true;
ModelConverterContextImpl myContext = new ModelConverterContextImpl(myModelResolver);
final Schema model = myContext.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" + " properties:\n" + " id:\n" + " type: integer\n" + " format: int64\n" + " model:\n" + " type: string\n" + " allOf:\n" + " - $ref: '#/components/schemas/Car'\n" + "SportCar:\n" + " required:\n" + " - id\n" + " type: object\n" + " properties:\n" + " id:\n" + " type: integer\n" + " format: int64\n" + " model:\n" + " type: string\n" + " allOf:\n" + " - $ref: '#/components/schemas/Car'\n";
SerializationMatchers.assertEqualsToYaml(myContext.getDefinedModels(), yaml);
ModelResolver.composedModelPropertiesAsSibling = false;
}
use of io.swagger.v3.core.converter.ModelConverterContextImpl in project swagger-core by swagger-api.
the class Ticket3697Test method testHiddenJsonCreator.
@Test
public void testHiddenJsonCreator() throws Exception {
final ModelResolver modelResolver = new ModelResolver(mapper());
ModelConverterContextImpl context = new ModelConverterContextImpl(modelResolver);
Schema model = context.resolve(new AnnotatedType(TestObject3697.class));
SerializationMatchers.assertEqualsToYaml(context.getDefinedModels(), "TestObject3697:\n" + " type: object\n" + " properties:\n" + " id:\n" + " type: integer\n" + " format: int64");
}
use of io.swagger.v3.core.converter.ModelConverterContextImpl 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.core.converter.ModelConverterContextImpl 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");
}
Aggregations