use of io.swagger.v3.jaxrs2.Reader in project swagger-core by swagger-api.
the class ReaderTest method testTicket3694.
@Test(description = "overridden generic resource methods")
public void testTicket3694() {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(Ticket3694ResourceExtendedType.class);
String yaml = "openapi: 3.0.1\n" + "paths:\n" + " /foo:\n" + " post:\n" + " tags:\n" + " - Foo\n" + " summary: Foo List in Interface\n" + " operationId: foo\n" + " requestBody:\n" + " content:\n" + " application/json:\n" + " schema:\n" + " type: array\n" + " items:\n" + " type: string\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " '*/*': {}\n" + " /bar:\n" + " post:\n" + " operationId: bar\n" + " requestBody:\n" + " content:\n" + " application/json:\n" + " schema:\n" + " type: array\n" + " items:\n" + " type: string\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " '*/*':\n" + " schema:\n" + " type: string\n" + " /another:\n" + " post:\n" + " operationId: another\n" + " requestBody:\n" + " content:\n" + " application/json:\n" + " schema:\n" + " type: string\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " '*/*': {}";
SerializationMatchers.assertEqualsToYaml(openAPI, yaml);
reader = new Reader(new OpenAPI());
openAPI = reader.read(Ticket3694Resource.class);
yaml = "openapi: 3.0.1\n" + "paths:\n" + " /foo:\n" + " post:\n" + " tags:\n" + " - Foo\n" + " summary: Foo List in Interface\n" + " operationId: foo\n" + " requestBody:\n" + " content:\n" + " application/json:\n" + " schema:\n" + " type: array\n" + " items:\n" + " type: string\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " '*/*': {}\n" + " /bar:\n" + " post:\n" + " operationId: bar\n" + " requestBody:\n" + " content:\n" + " application/json:\n" + " schema:\n" + " type: array\n" + " items:\n" + " type: string\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " '*/*':\n" + " schema:\n" + " type: string\n" + " /another:\n" + " post:\n" + " operationId: another\n" + " requestBody:\n" + " content:\n" + " application/json:\n" + " schema:\n" + " type: string\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " '*/*': {}";
SerializationMatchers.assertEqualsToYaml(openAPI, yaml);
reader = new Reader(new OpenAPI());
openAPI = reader.read(Ticket3694ResourceSimple.class);
yaml = "openapi: 3.0.1\n" + "paths:\n" + " /bar:\n" + " post:\n" + " operationId: bar\n" + " requestBody:\n" + " content:\n" + " application/json:\n" + " schema:\n" + " type: array\n" + " items:\n" + " type: string\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " '*/*':\n" + " schema:\n" + " type: string";
SerializationMatchers.assertEqualsToYaml(openAPI, yaml);
reader = new Reader(new OpenAPI());
openAPI = reader.read(Ticket3694ResourceSimpleSameReturn.class);
yaml = "openapi: 3.0.1\n" + "paths:\n" + " /bar:\n" + " post:\n" + " operationId: bar\n" + " requestBody:\n" + " content:\n" + " application/json:\n" + " schema:\n" + " type: array\n" + " items:\n" + " type: string\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " '*/*': {}";
SerializationMatchers.assertEqualsToYaml(openAPI, yaml);
}
use of io.swagger.v3.jaxrs2.Reader in project swagger-core by swagger-api.
the class ReaderTest method testGetSummaryAndDescription.
@Test(description = "Get a Summary and Description")
public void testGetSummaryAndDescription() {
Reader reader = new Reader(new OpenAPI());
Method[] methods = BasicFieldsResource.class.getMethods();
Operation operation = reader.parseMethod(methods[0], null, null);
assertNotNull(operation);
assertEquals(OPERATION_SUMMARY, operation.getSummary());
assertEquals(OPERATION_DESCRIPTION, operation.getDescription());
}
use of io.swagger.v3.jaxrs2.Reader in project swagger-core by swagger-api.
the class ReaderTest method testGetExternalDocs.
@Test(description = "External Docs")
public void testGetExternalDocs() {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(ExternalDocsReference.class);
Operation externalDocsOperation = openAPI.getPaths().get("/").getGet();
ExternalDocumentation externalDocs = externalDocsOperation.getExternalDocs();
assertEquals(externalDocs.getDescription(), "External documentation description in method");
assertEquals(externalDocs.getUrl(), EXTERNAL_DOCS_URL);
externalDocs = openAPI.getComponents().getSchemas().get("ExternalDocsSchema").getExternalDocs();
assertEquals("External documentation description in schema", externalDocs.getDescription());
assertEquals(externalDocs.getUrl(), EXTERNAL_DOCS_URL);
}
use of io.swagger.v3.jaxrs2.Reader in project swagger-core by swagger-api.
the class ReaderTest method testMoreResponses.
@Test(description = "More Responses")
public void testMoreResponses() {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(EnhancedResponsesResource.class);
String yaml = "openapi: 3.0.1\n" + "paths:\n" + " /:\n" + " get:\n" + " summary: Simple get operation\n" + " description: Defines a simple get operation with no inputs and a complex output\n" + " object\n" + " operationId: getWithPayloadResponse\n" + " responses:\n" + " \"200\":\n" + " description: voila!\n" + " content:\n" + " application/json:\n" + " schema:\n" + " $ref: '#/components/schemas/SampleResponseSchema'\n" + " \"404\":\n" + " description: not found!\n" + " \"400\":\n" + " description: boo\n" + " content:\n" + " '*/*':\n" + " schema:\n" + " $ref: '#/components/schemas/GenericError'\n" + " deprecated: true\n" + "components:\n" + " schemas:\n" + " GenericError:\n" + " type: object\n" + " SampleResponseSchema:\n" + " type: object\n";
SerializationMatchers.assertEqualsToYaml(openAPI, yaml);
}
use of io.swagger.v3.jaxrs2.Reader in project swagger-core by swagger-api.
the class EnumTest method testEnum.
@Test(description = "Test enum")
public void testEnum() throws IOException {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(EnumParameterResource.class);
SerializationMatchers.assertEqualsToYaml(openAPI, EXPECTED_YAML);
}
Aggregations