use of io.swagger.v3.core.util.Yaml 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.util.Yaml in project swagger-core by swagger-api.
the class Ticket3197Test method testTicket3197.
@Test
public void testTicket3197() throws Exception {
final Schema model = context.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" + " allOf:\n" + " - $ref: '#/components/schemas/Car'\n" + " - type: object\n" + " properties:\n" + " id:\n" + " type: integer\n" + " format: int64\n" + " model:\n" + " type: string\n" + "SportCar:\n" + " required:\n" + " - id\n" + " type: object\n" + " allOf:\n" + " - $ref: '#/components/schemas/Car'\n" + " - type: object\n" + " properties:\n" + " id:\n" + " type: integer\n" + " format: int64\n" + " model:\n" + " type: string\n";
SerializationMatchers.assertEqualsToYaml(context.getDefinedModels(), yaml);
}
use of io.swagger.v3.core.util.Yaml in project swagger-core by swagger-api.
the class ReaderTest method testTicket2144.
@Test(description = "non consistent overridden generic resource methods")
public void testTicket2144() {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(ItemResource.class);
String yaml = "openapi: 3.0.1\n" + "paths:\n" + " /item/{id}:\n" + " get:\n" + " operationId: getById\n" + " parameters:\n" + " - name: id\n" + " in: path\n" + " required: true\n" + " schema:\n" + " type: string\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " '*/*':\n" + " schema:\n" + " $ref: '#/components/schemas/ItemWithChildren'\n" + " /item/nogeneric/{id}:\n" + " get:\n" + " operationId: getByIdNoGeneric\n" + " parameters:\n" + " - name: id\n" + " in: path\n" + " required: true\n" + " schema:\n" + " type: string\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " '*/*':\n" + " schema:\n" + " $ref: '#/components/schemas/ItemWithChildren'\n" + " /item/nogenericsamereturn/{id}:\n" + " get:\n" + " operationId: getByIdNoGenericSameReturn\n" + " parameters:\n" + " - name: id\n" + " in: path\n" + " required: true\n" + " schema:\n" + " type: string\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " '*/*':\n" + " schema:\n" + " $ref: '#/components/schemas/BaseDTO'\n" + " /item/genericparam:\n" + " post:\n" + " operationId: genericParam\n" + " requestBody:\n" + " content:\n" + " '*/*':\n" + " schema:\n" + " $ref: '#/components/schemas/ItemWithChildren'\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " '*/*':\n" + " schema:\n" + " $ref: '#/components/schemas/BaseDTO'\n" + "components:\n" + " schemas:\n" + " ItemWithChildren:\n" + " type: object\n" + " properties:\n" + " name:\n" + " type: string\n" + " names:\n" + " type: string\n" + " BaseDTO:\n" + " type: object\n" + " properties:\n" + " name:\n" + " type: string";
SerializationMatchers.assertEqualsToYaml(openAPI, yaml);
}
use of io.swagger.v3.core.util.Yaml in project swagger-core by swagger-api.
the class ReaderTest method testTicket2763.
@Test(description = "Responses with array schema")
public void testTicket2763() {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(Ticket2763Resource.class);
String yaml = "openapi: 3.0.1\n" + "paths:\n" + " /array:\n" + " get:\n" + " operationId: getArrayResponses\n" + " responses:\n" + " default:\n" + " content:\n" + " application/json:\n" + " schema:\n" + " type: array\n" + " items:\n" + " $ref: https://openebench.bsc.es/monitor/tool/tool.json\n" + " /schema:\n" + " get:\n" + " operationId: getSchemaResponses\n" + " responses:\n" + " default:\n" + " content:\n" + " application/json:\n" + " schema:\n" + " $ref: https://openebench.bsc.es/monitor/tool/tool.json";
SerializationMatchers.assertEqualsToYaml(openAPI, yaml);
}
use of io.swagger.v3.core.util.Yaml in project swagger-core by swagger-api.
the class ReaderTest method testTicket3149.
@Test(description = "overridden generic resource interface default methods")
public void testTicket3149() {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(MainResource.class);
String yaml = "openapi: 3.0.1\n" + "paths:\n" + " /test:\n" + " post:\n" + " tags:\n" + " - Test inheritance on default implementation in interfaces\n" + " operationId: firstEndpoint\n" + " requestBody:\n" + " content:\n" + " '*/*':\n" + " schema:\n" + " $ref: '#/components/schemas/SampleDTO'\n" + " responses:\n" + " \"201\":\n" + " description: Created\n" + " \"400\":\n" + " description: Bad Request\n" + " \"403\":\n" + " description: Forbidden\n" + " \"404\":\n" + " description: Not Found\n" + " /test/{id}:\n" + " get:\n" + " tags:\n" + " - Test inheritance on default implementation in interfaces\n" + " operationId: secondEnpoint\n" + " requestBody:\n" + " content:\n" + " '*/*':\n" + " schema:\n" + " $ref: '#/components/schemas/SampleOtherDTO'\n" + " responses:\n" + " \"200\":\n" + " description: OK\n" + " \"400\":\n" + " description: Bad Request\n" + " \"403\":\n" + " description: Forbidden\n" + " \"404\":\n" + " description: Not Found\n" + " /test/original/{id}:\n" + " get:\n" + " tags:\n" + " - Test inheritance on default implementation in interfaces\n" + " operationId: originalEndpoint\n" + " requestBody:\n" + " content:\n" + " '*/*':\n" + " schema:\n" + " $ref: '#/components/schemas/SampleOtherDTO'\n" + " responses:\n" + " \"200\":\n" + " description: OK\n" + " \"400\":\n" + " description: Bad Request\n" + " \"403\":\n" + " description: Forbidden\n" + " \"404\":\n" + " description: Not Found\n" + "components:\n" + " schemas:\n" + " SampleDTO:\n" + " type: object\n" + " properties:\n" + " name:\n" + " type: string\n" + " SampleOtherDTO:\n" + " type: object\n" + " properties:\n" + " label:\n" + " type: string";
SerializationMatchers.assertEqualsToYaml(openAPI, yaml);
}
Aggregations