use of io.swagger.v3.core.util.Yaml in project swagger-core by swagger-api.
the class ReaderTest method testTicket3426.
@Test(description = "overridden generic resource methods operationId")
public void testTicket3426() {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(Ticket3426Resource.class);
String yaml = "openapi: 3.0.1\n" + "paths:\n" + " /inheritExample/{input}:\n" + " get:\n" + " operationId: get\n" + " parameters:\n" + " - name: input\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" + " 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 testSingleExample.
@Test(description = "Single Example")
public void testSingleExample() {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(SingleExampleResource.class);
String yaml = "openapi: 3.0.1\n" + "paths:\n" + " /test1:\n" + " post:\n" + " operationId: test1\n" + " requestBody:\n" + " content:\n" + " application/json:\n" + " schema:\n" + " $ref: '#/components/schemas/User'\n" + " example:\n" + " foo: foo\n" + " bar: bar\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " '*/*': {}\n" + " /test2:\n" + " post:\n" + " operationId: test2\n" + " requestBody:\n" + " content:\n" + " application/json:\n" + " schema:\n" + " $ref: '#/components/schemas/User'\n" + " example:\n" + " foo: foo\n" + " bar: bar\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " '*/*': {}\n" + "components:\n" + " schemas:\n" + " User:\n" + " type: object\n" + " properties:\n" + " id:\n" + " type: integer\n" + " format: int64\n" + " username:\n" + " type: string\n" + " firstName:\n" + " type: string\n" + " lastName:\n" + " type: string\n" + " email:\n" + " type: string\n" + " password:\n" + " type: string\n" + " phone:\n" + " type: string\n" + " userStatus:\n" + " type: integer\n" + " description: User Status\n" + " format: int32\n" + " xml:\n" + " name: User\n";
SerializationMatchers.assertEqualsToYaml(openAPI, yaml);
}
use of io.swagger.v3.core.util.Yaml in project swagger-core by swagger-api.
the class ReaderTest method testRequestBodyEncoding.
@Test
public void testRequestBodyEncoding() {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(UrlEncodedResourceWithEncodings.class);
String yaml = "openapi: 3.0.1\n" + "paths:\n" + " /things/search:\n" + " post:\n" + " operationId: searchForThings\n" + " requestBody:\n" + " content:\n" + " application/x-www-form-urlencoded:\n" + " schema:\n" + " type: object\n" + " properties:\n" + " id:\n" + " type: array\n" + " description: id param\n" + " items:\n" + " type: string\n" + " name:\n" + " type: array\n" + " items:\n" + " type: string\n" + " encoding:\n" + " id:\n" + " style: form\n" + " explode: true\n" + " name:\n" + " style: form\n" + " explode: false\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " application/json: {}\n" + " /things/sriracha:\n" + " post:\n" + " operationId: srirachaThing\n" + " requestBody:\n" + " content:\n" + " application/x-www-form-urlencoded:\n" + " schema:\n" + " type: object\n" + " properties:\n" + " id:\n" + " type: array\n" + " description: id param\n" + " items:\n" + " type: string\n" + " name:\n" + " type: array\n" + " items:\n" + " type: string\n" + " encoding:\n" + " id:\n" + " style: form\n" + " explode: true\n" + " name:\n" + " style: form\n" + " explode: false\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " application/json: {}\n";
SerializationMatchers.assertEqualsToYaml(openAPI, yaml);
}
use of io.swagger.v3.core.util.Yaml in project swagger-core by swagger-api.
the class ReaderTest method testTicket2793.
/*
TODO: in a scenario like the one in ticket 2793, currently no NPE is thrown
but map is still not supported. When solved, update expected yaml in test case accordingly
*/
@Test(description = "no NPE resolving map")
public void testTicket2793() {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(Ticket2793Resource.class);
String yaml = "openapi: 3.0.1\n" + "paths:\n" + " /distances:\n" + " get:\n" + " operationId: getDistances\n" + " responses:\n" + " \"200\":\n" + " content:\n" + " application/json:\n" + " schema:\n" + " $ref: '#/components/schemas/DistancesResponse'\n" + "components:\n" + " schemas:\n" + " DistancesResponse:\n" + " type: object\n" + " properties:\n" + " empty:\n" + " type: boolean\n";
SerializationMatchers.assertEqualsToYaml(openAPI, yaml);
}
use of io.swagger.v3.core.util.Yaml in project swagger-core by swagger-api.
the class ReaderTest method testTicket2794.
@Test(description = "NotNull parameters")
public void testTicket2794() {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(Ticket2794Resource.class);
String yaml = "openapi: 3.0.1\n" + "paths:\n" + " /notnullparameter:\n" + " get:\n" + " operationId: getBooks\n" + " parameters:\n" + " - name: page\n" + " in: query\n" + " required: true\n" + " schema:\n" + " type: integer\n" + " format: int32\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " application/json: {}\n" + " /notnullparameter/newnotnull:\n" + " post:\n" + " operationId: insertnotnull\n" + " requestBody:\n" + " content:\n" + " '*/*':\n" + " schema:\n" + " $ref: '#/components/schemas/Book'\n" + " required: true\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " '*/*': {}\n" + " /notnullparameter/new_reqBody_required:\n" + " post:\n" + " operationId: insert\n" + " requestBody:\n" + " content:\n" + " '*/*':\n" + " schema:\n" + " $ref: '#/components/schemas/Book'\n" + " required: true\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " '*/*': {}\n" + "components:\n" + " schemas:\n" + " Book:\n" + " type: object\n" + " properties:\n" + " foo:\n" + " type: string\n";
SerializationMatchers.assertEqualsToYaml(openAPI, yaml);
}
Aggregations