use of io.swagger.v3.core.converter.AnnotatedType in project swagger-core by swagger-api.
the class Ticket3624Test method testSelfReferencingOptional.
@Test
public void testSelfReferencingOptional() throws Exception {
final ModelResolver modelResolver = new ModelResolver(mapper());
ModelConverterContextImpl context = new ModelConverterContextImpl(modelResolver);
Schema model = context.resolve(new AnnotatedType(ModelContainer.class));
Yaml.prettyPrint(context.getDefinedModels());
SerializationMatchers.assertEqualsToYaml(context.getDefinedModels(), "Model:\n" + " type: object\n" + " properties:\n" + " model:\n" + " $ref: '#/components/schemas/Model'\n" + "ModelContainer:\n" + " type: object\n" + " properties:\n" + " model:\n" + " $ref: '#/components/schemas/Model'\n");
}
use of io.swagger.v3.core.converter.AnnotatedType in project swagger-core by swagger-api.
the class Ticket3703Test method testSelfReferencingOptional.
@Test
public void testSelfReferencingOptional() throws Exception {
final ModelResolver modelResolver = new ModelResolver(mapper());
ModelConverterContextImpl context = new ModelConverterContextImpl(modelResolver);
Schema model = context.resolve(new AnnotatedType(ModelContainer.class));
SerializationMatchers.assertEqualsToYaml(context.getDefinedModels(), "Model:\n" + " type: object\n" + " properties:\n" + " model:\n" + " $ref: '#/components/schemas/Model'\n" + "ModelContainer:\n" + " type: object\n" + " properties:\n" + " model:\n" + " $ref: '#/components/schemas/Model'\n" + " bytes:\n" + " type: string\n" + " format: byte");
}
use of io.swagger.v3.core.converter.AnnotatedType in project swagger-core by swagger-api.
the class Ticket3030Test method testTicket3030.
@Test
public void testTicket3030() throws Exception {
final Schema model = context.resolve(new AnnotatedType(Child.class));
assertNotNull(model);
String yaml = "Child:\n" + " type: object\n" + " allOf:\n" + " - $ref: '#/components/schemas/Parent'\n" + " - type: object\n" + " properties:\n" + " property:\n" + " type: string\n" + "Parent:\n" + " type: object\n" + " properties:\n" + " sharedProperty:\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 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.AnnotatedType 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");
}
Aggregations