use of io.swagger.v3.core.util.Yaml in project swagger-core by swagger-api.
the class OpenAPI3_1DeserializationTest method deserializeChangelog3_1.
@Test
public void deserializeChangelog3_1() throws IOException {
final String jsonString = ResourceUtils.loadClassResource(getClass(), "specFiles/3.1.0/changelog-3.1.yaml");
final OpenAPI swagger = Yaml31.mapper().readValue(jsonString, OpenAPI.class);
assertNotNull(swagger);
assertEquals(swagger.getInfo().getLicense().getIdentifier(), "test");
Yaml31.prettyPrint(swagger);
SerializationMatchers.assertEqualsToYaml31(swagger, jsonString);
}
use of io.swagger.v3.core.util.Yaml in project swagger-core by swagger-api.
the class Ticket2926Test method testExtensionsInMapDeserializeAndSerialize.
@Test
public void testExtensionsInMapDeserializeAndSerialize() throws Exception {
String yaml = "openapi: 3.0.1\n" + "info:\n" + " title: My title\n" + " description: API under test\n" + " version: 1.0.7\n" + " x-info: test\n" + "servers:\n" + "- url: http://localhost:9999/api\n" + " x-server: test\n" + " description: desc\n" + " variables: \n" + " serVar: \n" + " description: desc\n" + " x-serverVariable: test\n" + "paths:\n" + " /foo/bar:\n" + " get:\n" + " callbacks:\n" + " /foo/bar:\n" + " get:\n" + " description: getoperation\n" + " x-callback: test\n" + " responses:\n" + " default:\n" + " description: it works!\n" + " content:\n" + " application/json:\n" + " schema:\n" + " title: inline_response_200\n" + " type: object\n" + " properties:\n" + " name:\n" + " type: string\n" + " x-mediatype: test\n" + " x-response: test\n" + " x-responses: test\n" + " x-responses-object: \n" + " aaa: bbb\n" + " x-responses-array: \n" + " - aaa\n" + " - bbb\n" + " x-operation: test\n" + " x-pathitem: test\n" + " x-paths: test\n" + "x-openapi-object: \n" + " aaa: bbb\n" + "x-openapi-array: \n" + " - aaa\n" + " - bbb\n" + "x-openapi: test";
OpenAPI aa = Yaml.mapper().readValue(yaml, OpenAPI.class);
SerializationMatchers.assertEqualsToYaml(aa, yaml);
}
use of io.swagger.v3.core.util.Yaml 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);
}
use of io.swagger.v3.core.util.Yaml 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.util.Yaml 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;
}
Aggregations