use of io.swagger.v3.jaxrs2.Reader in project swagger-core by swagger-api.
the class ReaderTest method testExampleWithRef.
@Test(description = "Example with ref")
public void testExampleWithRef() {
Components components = new Components();
components.addExamples("Id", new Example().description("Id Example").summary("Id Example").value("1"));
OpenAPI oas = new OpenAPI().info(new Info().description("info")).components(components);
Reader reader = new Reader(oas);
OpenAPI openAPI = reader.read(RefExamplesResource.class);
String yaml = "openapi: 3.0.1\n" + "info:\n" + " description: info\n" + "paths:\n" + " /example:\n" + " post:\n" + " description: subscribes a client to updates relevant to the requestor's account\n" + " operationId: subscribe\n" + " parameters:\n" + " - name: subscriptionId\n" + " in: path\n" + " required: true\n" + " style: simple\n" + " schema:\n" + " type: string\n" + " description: Schema\n" + " example: Subscription example\n" + " examples:\n" + " subscriptionId_1:\n" + " summary: Subscription number 12345\n" + " description: subscriptionId_1\n" + " value: 12345\n" + " externalValue: Subscription external value 1\n" + " $ref: '#/components/examples/Id'\n" + " example: example\n" + " requestBody:\n" + " content:\n" + " '*/*':\n" + " schema:\n" + " type: integer\n" + " format: int32\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " '*/*':\n" + " schema:\n" + " $ref: '#/components/schemas/SubscriptionResponse'\n" + "components:\n" + " schemas:\n" + " SubscriptionResponse:\n" + " type: object\n" + " properties:\n" + " subscriptionId:\n" + " type: string\n" + " examples:\n" + " Id:\n" + " summary: Id Example\n" + " description: Id Example\n" + " value: \"1\"\n";
SerializationMatchers.assertEqualsToYaml(openAPI, yaml);
}
use of io.swagger.v3.jaxrs2.Reader in project swagger-core by swagger-api.
the class JaxrsApplicationAndAnnotationScannerTest method shouldScanClassesFromPackages.
@Test(description = "scan a simple resource from packages")
public void shouldScanClassesFromPackages() throws Exception {
SwaggerConfiguration config = new SwaggerConfiguration().resourcePackages(Stream.of("com.my.project.resources", "org.my.project.resources").collect(Collectors.toSet())).openAPI(new OpenAPI().info(new Info().description("TEST INFO DESC")));
OpenApiContext ctx = new GenericOpenApiContext<>().openApiConfiguration(config).openApiReader(new Reader(config)).openApiScanner(scanner.application(null).openApiConfiguration(config)).init();
OpenAPI openApi = ctx.read();
assertNotNull(openApi);
assertEquals(openApi.getPaths().keySet(), Arrays.asList("/packageA", "/packageB"));
}
use of io.swagger.v3.jaxrs2.Reader in project swagger-core by swagger-api.
the class JsonIdentityTest method testJsonIdentityCyclic.
@Test(description = "Test JsonIdentity Cyclic")
public void testJsonIdentityCyclic() throws IOException {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(JsonIdentityCyclicResource.class);
SerializationMatchers.assertEqualsToYaml(openAPI, EXPECTED_YAML_CYCLIC);
}
Aggregations