use of io.swagger.v3.oas.models.media.Discriminator in project swagger-parser by swagger-api.
the class V2ConverterTest method testIssue27.
@Test(description = "500 Error Models with discriminator")
public void testIssue27() throws Exception {
OpenAPI oas = getConvertedOpenAPIFromJsonFile(ISSUE_27_JSON);
assertEquals(REQUIRED_SIZE, oas.getComponents().getSchemas().get(PET_SCHEMA).getRequired().size());
}
use of io.swagger.v3.oas.models.media.Discriminator in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testDiscriminatorSameFileExternalMapping.
@Test
public void testDiscriminatorSameFileExternalMapping() throws Exception {
OpenAPI openAPI = new OpenAPIV3Parser().read("./discriminator-mapping-resolution/main-external-mapping.yaml");
Assert.assertNotNull(openAPI);
Schema cat = openAPI.getComponents().getSchemas().get("Cat");
Assert.assertNotNull(cat);
}
use of io.swagger.v3.oas.models.media.Discriminator in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testDiscriminatorSeparateFilePlainMapping.
@Test
public void testDiscriminatorSeparateFilePlainMapping() throws Exception {
OpenAPI openAPI = new OpenAPIV3Parser().read("./discriminator-mapping-resolution/main-plain-mapping.yaml");
Assert.assertNotNull(openAPI);
Schema cat = openAPI.getComponents().getSchemas().get("Cat");
Assert.assertNotNull(cat);
}
use of io.swagger.v3.oas.models.media.Discriminator in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testDiscriminatorSeparateFileNoMapping.
@Test
public void testDiscriminatorSeparateFileNoMapping() throws Exception {
OpenAPI openAPI = new OpenAPIV3Parser().read("./discriminator-mapping-resolution/main-no-mapping.yaml");
Assert.assertNotNull(openAPI);
Schema cat = openAPI.getComponents().getSchemas().get("Cat");
// FIXME, issue #970 still exists in this form
Assert.assertNull(cat);
}
use of io.swagger.v3.oas.models.media.Discriminator in project swagger-core by swagger-api.
the class Ticket3063Test method testTicket3063.
@Test
public void testTicket3063() throws Exception {
final Schema model = context.resolve(new AnnotatedType(BaseClass.class));
assertNotNull(model);
String yaml = "BaseClass:\n" + " required:\n" + " - type\n" + " type: object\n" + " properties:\n" + " type:\n" + " type: string\n" + " description: Type\n" + " example: AndroidDeviceRequirements\n" + " description: test\n" + " discriminator:\n" + " propertyName: type\n" + "SubClass:\n" + " required:\n" + " - type\n" + " type: object\n" + " description: SubClass\n" + " allOf:\n" + " - $ref: '#/components/schemas/BaseClass'\n" + " - type: object\n" + " properties:\n" + " additionalPropertyWhichShouldBeThere:\n" + " type: integer\n" + " description: Test\n" + " format: int32";
SerializationMatchers.assertEqualsToYaml(context.getDefinedModels(), yaml);
}
Aggregations