org.jboss.jandex.Index Java Examples

The following examples show how to use org.jboss.jandex.Index. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JaxRsAnnotationScannerTest.java    From smallrye-open-api with Apache License 2.0 6 votes vote down vote up
@Test
public void testTagScanning_OrderGivenStaticFile() throws IOException, JSONException {
    Index i = indexOf(TagTestResource1.class, TagTestResource2.class);
    OpenApiAnnotationScanner scanner = new OpenApiAnnotationScanner(nestingSupportConfig(), i);
    OpenAPI scanResult = scanner.scan();
    OpenAPI staticResult = OpenApiParser.parse(new ByteArrayInputStream(
            "{\"info\" : {\"title\" : \"Tag order in static file\",\"version\" : \"1.0.0-static\"},\"tags\": [{\"name\":\"tag3\"},{\"name\":\"tag1\"}]}"
                    .getBytes()),
            Format.JSON);
    OpenApiDocument doc = OpenApiDocument.INSTANCE;
    doc.config(nestingSupportConfig());
    doc.modelFromStaticFile(staticResult);
    doc.modelFromAnnotations(scanResult);
    doc.initialize();
    OpenAPI result = doc.get();
    printToConsole(result);
    assertJsonEquals("resource.tags.ordergiven.staticfile.json", result);
}
 
Example #2
Source File: PanacheMockBuildChainCustomizer.java    From quarkus with Apache License 2.0 6 votes vote down vote up
@Override
public Consumer<BuildChainBuilder> produce(Index testClassesIndex) {
    return new Consumer<BuildChainBuilder>() {

        @Override
        public void accept(BuildChainBuilder buildChainBuilder) {
            buildChainBuilder.addBuildStep(new BuildStep() {
                @Override
                public void execute(BuildContext context) {
                    LaunchModeBuildItem launchMode = context.consume(LaunchModeBuildItem.class);
                    if (launchMode.getLaunchMode() == LaunchMode.TEST) {
                        context.produce(new PanacheMethodCustomizerBuildItem(new PanacheMockMethodCustomizer()));
                    }
                }
            }).produces(PanacheMethodCustomizerBuildItem.class)
                    .consumes(LaunchModeBuildItem.class)
                    .build();
        }
    };
}
 
Example #3
Source File: CustomExtensionParsingTests.java    From smallrye-open-api with Apache License 2.0 6 votes vote down vote up
@Test
public void testCustomAnnotationScannerExtension() {
    Index index = IndexScannerTestBase.indexOf(ExtensionParsingTestResource.class);
    OpenApiAnnotationScanner scanner = new OpenApiAnnotationScanner(IndexScannerTestBase.emptyConfig(), index,
            Arrays.asList(new AnnotationScannerExtension() {
                @Override
                public Object parseExtension(String name, String value) {
                    /*
                     * "parsing" consists of creating a singleton map with the
                     * extension name as the key and the unparsed value as the value
                     */
                    return Collections.singletonMap(name, value);
                }
            }));

    OpenAPI result = scanner.scan();
    org.eclipse.microprofile.openapi.models.callbacks.Callback cb;
    cb = result.getPaths().getPathItem("/ext-custom").getPOST().getCallbacks().get("extendedCallback");
    Map<String, Object> ext = cb.getPathItem("http://localhost:8080/resources/ext-callback").getGET().getExtensions();
    assertEquals(4, ext.size());
    assertEquals(Collections.singletonMap("x-object", "{ \"key\":\"value\" }"), ext.get("x-object"));
    assertEquals("{ \"key\":\"value\" }", ext.get("x-object-unparsed"));
    assertEquals(Collections.singletonMap("x-array", "[ \"val1\",\"val2\" ]"), ext.get("x-array"));
    assertEquals("true", ext.get("x-booltrue"));
}
 
Example #4
Source File: CompositeIndexProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private Index calculateModuleIndex(final Module module) throws ModuleLoadException, IOException {
    final Indexer indexer = new Indexer();
    final PathFilter filter = PathFilters.getDefaultImportFilter();
    final Iterator<Resource> iterator = module.iterateResources(filter);
    while (iterator.hasNext()) {
        Resource resource = iterator.next();
        if(resource.getName().endsWith(".class")) {
            try (InputStream in = resource.openStream()) {
                indexer.index(in);
            } catch (Exception e) {
                ServerLogger.DEPLOYMENT_LOGGER.cannotIndexClass(resource.getName(), resource.getURL().toExternalForm(), e);
            }
        }
    }
    return indexer.complete();
}
 
Example #5
Source File: TypeUtil.java    From serianalyzer with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 
 * @param i
 * @param methodReference
 * @param ci
 * @return whether any superclass implements the method
 */
public static boolean implementsMethodRecursive ( Index i, MethodReference methodReference, ClassInfo ci ) {
    if ( implementsMethod(methodReference, ci) ) {
        return true;
    }

    DotName superName = ci.superName();
    if ( superName != null ) {
        ClassInfo superByName = i.getClassByName(superName);
        if ( superByName == null || "java.lang.Object".equals(superByName.name().toString()) ) { //$NON-NLS-1$
            return false;
        }

        return implementsMethodRecursive(i, methodReference, superByName);
    }
    return false;
}
 
Example #6
Source File: ResourceParameterTests.java    From smallrye-open-api with Apache License 2.0 6 votes vote down vote up
/*************************************************************************/

    /*
     * Test case derived from original example in Smallrye OpenAPI issue #201.
     *
     * https://github.com/smallrye/smallrye-open-api/issues/201
     *
     */
    @Test
    public void testSchemaImplementationType() throws IOException, JSONException {
        Index i = indexOf(SchemaImplementationTypeResource.class,
                SchemaImplementationTypeResource.GreetingMessage.class,
                SchemaImplementationTypeResource.SimpleString.class);

        OpenApiConfig config = emptyConfig();
        IndexView filtered = new FilteredIndexView(i, config);
        OpenApiAnnotationScanner scanner = new OpenApiAnnotationScanner(config, filtered);
        OpenAPI result = scanner.scan();
        printToConsole(result);
        assertJsonEquals("resource.parameters.string-implementation-wrapped.json", result);
    }
 
Example #7
Source File: ResourceParameterTests.java    From smallrye-open-api with Apache License 2.0 6 votes vote down vote up
/*************************************************************************/

    /*
     * Test case derived for Smallrye OpenAPI issue #233.
     *
     * https://github.com/smallrye/smallrye-open-api/issues/233
     *
     */
    @Test
    public void testTimeResource() throws IOException, JSONException {
        Index i = indexOf(TimeTestResource.class, TimeTestResource.UTC.class, LocalTime.class, OffsetTime.class);
        OpenApiAnnotationScanner scanner = new OpenApiAnnotationScanner(nestingSupportConfig(), i);
        OpenAPI result = scanner.scan();
        printToConsole(result);
        assertJsonEquals("resource.parameters.time.json", result);
    }
 
Example #8
Source File: ResourceParameterTests.java    From smallrye-open-api with Apache License 2.0 6 votes vote down vote up
/*************************************************************************/

    /*
     * Test case derived from original example in SmallRye OpenAPI issue #237.
     *
     * https://github.com/smallrye/smallrye-open-api/issues/237
     *
     */
    @Test
    public void testTypeVariableResponse() throws IOException, JSONException {
        Index i = indexOf(TypeVariableResponseTestResource.class,
                TypeVariableResponseTestResource.Dto.class);
        OpenApiConfig config = emptyConfig();
        IndexView filtered = new FilteredIndexView(i, config);
        OpenApiAnnotationScanner scanner = new OpenApiAnnotationScanner(config, filtered);
        OpenAPI result = scanner.scan();
        printToConsole(result);
        assertJsonEquals("resource.parameters.type-variable.json", result);
    }
 
Example #9
Source File: RolesAllowedScopeScanTests.java    From smallrye-open-api with Apache License 2.0 6 votes vote down vote up
@Test
public void testClassRolesAllowedGeneratedScheme() throws IOException {
    Index index = indexOf(RolesAllowedApp.class, RolesAllowedResource1.class);
    OpenApiConfig config = emptyConfig();
    IndexView filtered = new FilteredIndexView(index, config);
    OpenApiAnnotationScanner scanner = new OpenApiAnnotationScanner(config, filtered);
    OpenAPI result = scanner.scan();
    printToConsole(result);
    SecurityRequirement requirement = result.getPaths().getPathItem("/v1/secured").getGET().getSecurity().get(0);
    assertNotNull(requirement);
    assertEquals(1, requirement.getScheme("rolesScheme").size());
    assertEquals("admin", requirement.getScheme("rolesScheme").get(0));
    assertEquals("admin",
            result.getComponents()
                    .getSecuritySchemes()
                    .get("rolesScheme")
                    .getFlows()
                    .getClientCredentials()
                    .getScopes()
                    .keySet()
                    .iterator().next());
}
 
Example #10
Source File: ResourceParameterTests.java    From smallrye-open-api with Apache License 2.0 6 votes vote down vote up
/*************************************************************************/

    /*
     * Test cases derived from original example in SmallRye OpenAPI issue #260.
     *
     * https://github.com/smallrye/smallrye-open-api/issues/260
     *
     */
    @Test
    public void testGenericSetResponseWithSetIndexed() throws IOException, JSONException {
        Index i = indexOf(FruitResource.class, Fruit.class, Seed.class, Set.class);
        OpenApiAnnotationScanner scanner = new OpenApiAnnotationScanner(emptyConfig(), i);
        OpenAPI result = scanner.scan();
        printToConsole(result);
        assertJsonEquals("responses.generic-collection.set-indexed.json", result);
    }
 
Example #11
Source File: RolesAllowedScopeScanTests.java    From smallrye-open-api with Apache License 2.0 6 votes vote down vote up
@Test
public void testDeclaredRolesMethodRolesAllowedGeneratedScheme() throws IOException {
    Index index = indexOf(RolesAllowedApp.class, RolesDeclaredResource.class);
    OpenApiConfig config = emptyConfig();
    IndexView filtered = new FilteredIndexView(index, config);
    OpenApiAnnotationScanner scanner = new OpenApiAnnotationScanner(config, filtered);
    OpenAPI result = scanner.scan();
    printToConsole(result);
    SecurityRequirement requirement = result.getPaths().getPathItem("/v1/secured").getGET().getSecurity().get(0);
    assertNotNull(requirement);
    assertEquals(1, requirement.getScheme("rolesScheme").size());
    assertEquals("admin", requirement.getScheme("rolesScheme").get(0));
    assertArrayEquals(new String[] { "admin", "users" },
            result.getComponents()
                    .getSecuritySchemes()
                    .get("rolesScheme")
                    .getFlows()
                    .getClientCredentials()
                    .getScopes()
                    .keySet()
                    .toArray());
}
 
Example #12
Source File: ResourceParameterTests.java    From smallrye-open-api with Apache License 2.0 6 votes vote down vote up
/*************************************************************************/
/*
 * Test case derived from original example in SmallRye OpenAPI issue #330.
 *
 * https://github.com/smallrye/smallrye-open-api/issues/330
 *
 */

@Test
public void testMethodTargetParametersWithoutJAXRS() throws IOException, JSONException {
    Index i = indexOf(MethodTargetParametersResource.class,
            MethodTargetParametersResource.PagedResponse.class);
    OpenApiAnnotationScanner scanner = new OpenApiAnnotationScanner(emptyConfig(), i);
    OpenAPI result = scanner.scan();
    printToConsole(result);
    assertJsonEquals("params.method-target-nojaxrs.json", result);
}
 
Example #13
Source File: SimpleGeneratorTest.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BeforeAll
public static void init() throws IOException {
    TestClassOutput classOutput = new TestClassOutput();
    Index index = index(MyService.class, PublicMyService.class, BaseService.class, MyItem.class, String.class,
            CompletionStage.class,
            List.class);
    ValueResolverGenerator generator = new ValueResolverGenerator(index, classOutput, Collections.emptyMap());
    ClassInfo myServiceClazz = index.getClassByName(DotName.createSimple(MyService.class.getName()));
    generator.generate(myServiceClazz);
    generator.generate(index.getClassByName(DotName.createSimple(PublicMyService.class.getName())));
    generator.generate(index.getClassByName(DotName.createSimple(MyItem.class.getName())));
    generator.generate(index.getClassByName(DotName.createSimple(String.class.getName())));
    generator.generate(index.getClassByName(DotName.createSimple(List.class.getName())));
    generatedTypes.addAll(generator.getGeneratedTypes());

    ExtensionMethodGenerator extensionMethodGenerator = new ExtensionMethodGenerator(classOutput);
    MethodInfo extensionMethod = index.getClassByName(DotName.createSimple(MyService.class.getName())).method(
            "getDummy", Type.create(myServiceClazz.name(), Kind.CLASS), PrimitiveType.INT,
            Type.create(DotName.createSimple(String.class.getName()), Kind.CLASS));
    extensionMethodGenerator.generate(extensionMethod, null, null);
    extensionMethod = index.getClassByName(DotName.createSimple(MyService.class.getName())).method(
            "getDummy", Type.create(myServiceClazz.name(), Kind.CLASS), PrimitiveType.INT,
            PrimitiveType.LONG);
    extensionMethodGenerator.generate(extensionMethod, null, null);
    extensionMethod = index.getClassByName(DotName.createSimple(MyService.class.getName())).method(
            "getDummyVarargs", Type.create(myServiceClazz.name(), Kind.CLASS), PrimitiveType.INT,
            Type.create(DotName.createSimple("[L" + String.class.getName() + ";"), Kind.ARRAY));
    extensionMethodGenerator.generate(extensionMethod, null, null);
    generatedTypes.addAll(extensionMethodGenerator.getGeneratedTypes());
}
 
Example #14
Source File: SchemaFactoryTest.java    From smallrye-open-api with Apache License 2.0 5 votes vote down vote up
@Test
public void testResolveAsyncType() {
    Index index = indexOf();
    Type STRING_TYPE = Type.create(DotName.createSimple(String.class.getName()), Type.Kind.CLASS);
    Type target = ParameterizedType.create(DotName.createSimple(CompletableFuture.class.getName()),
            new Type[] { STRING_TYPE },
            null);
    Type result = SchemaFactory.resolveAsyncType(index, target, Collections.emptyList());
    assertEquals(STRING_TYPE, result);
}
 
Example #15
Source File: Basics.java    From quarkus with Apache License 2.0 5 votes vote down vote up
public static Index index(Class<?>... classes) throws IOException {
    Indexer indexer = new Indexer();
    for (Class<?> clazz : classes) {
        try (InputStream stream = Basics.class.getClassLoader()
                .getResourceAsStream(clazz.getName().replace('.', '/') + ".class")) {
            indexer.index(stream);
        }
    }
    return indexer.complete();
}
 
Example #16
Source File: BeanInfoTypesTest.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@Test
public void testResolver() throws IOException {

    Index index = index(Foo.class, Bar.class, FooQualifier.class, AbstractList.class, AbstractCollection.class,
            Collection.class, List.class,
            Iterable.class, Object.class, String.class);

    BeanDeployment deployment = BeanProcessor.builder().setIndex(index).build().getBeanDeployment();
    DotName fooName = name(Foo.class);

    ClassInfo fooClass = index.getClassByName(fooName);
    BeanInfo fooBean = Beans.createClassBean(fooClass, deployment, null);
    Set<Type> types = fooBean.getTypes();
    // Foo, AbstractList<String>, AbstractCollection<String>, List<String>, Collection<String>, Iterable<String>, Object
    assertEquals(7, types.size());
    assertTrue(types.contains(Type.create(fooName, Kind.CLASS)));
    assertTrue(types.contains(ParameterizedType.create(name(AbstractList.class),
            new Type[] { Type.create(name(String.class), Kind.CLASS) }, null)));
    assertTrue(types.contains(
            ParameterizedType.create(name(List.class), new Type[] { Type.create(name(String.class), Kind.CLASS) }, null)));
    assertTrue(types.contains(ParameterizedType.create(name(Collection.class),
            new Type[] { Type.create(name(String.class), Kind.CLASS) }, null)));
    assertTrue(types.contains(ParameterizedType.create(name(AbstractCollection.class),
            new Type[] { Type.create(name(String.class), Kind.CLASS) }, null)));
    assertTrue(types.contains(ParameterizedType.create(name(Iterable.class),
            new Type[] { Type.create(name(String.class), Kind.CLASS) }, null)));

}
 
Example #17
Source File: DotNamesTest.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@Test
public void testSimpleName() throws IOException {
    Index index = index(Nested.class, NestedNested.class, DotNamesTest.class);
    Assertions.assertEquals("Nested",
            DotNames.simpleName(index.getClassByName(DotName.createSimple(Nested.class.getName()))));
    assertEquals("DotNamesTest$Nested",
            DotNames.simpleName(index.getClassByName(DotName.createSimple(Nested.class.getName())).name()));
    assertEquals("NestedNested",
            DotNames.simpleName(index.getClassByName(DotName.createSimple(NestedNested.class.getName()))));
    assertEquals("DotNamesTest$Nested$NestedNested",
            DotNames.simpleName(index.getClassByName(DotName.createSimple(NestedNested.class.getName())).name()));
    assertEquals("DotNamesTest",
            DotNames.simpleName(index.getClassByName(DotName.createSimple(DotNamesTest.class.getName()))));
    assertEquals("DotNamesTest$Nested", DotNames.simpleName("io.quarkus.arc.processor.DotNamesTest$Nested"));
}
 
Example #18
Source File: ArcTestContainer.java    From quarkus with Apache License 2.0 5 votes vote down vote up
private Index index(Iterable<Class<?>> classes) throws IOException {
    Indexer indexer = new Indexer();
    for (Class<?> clazz : classes) {
        try (InputStream stream = ArcTestContainer.class.getClassLoader()
                .getResourceAsStream(clazz.getName().replace('.', '/') + ".class")) {
            indexer.index(stream);
        }
    }
    return indexer.complete();
}
 
Example #19
Source File: JandexUtilTest.java    From quarkus with Apache License 2.0 5 votes vote down vote up
private void checkRepoArg(Index index, Class<?> baseClass, Class<?> soughtClass, String expectedArg) {
    List<Type> args = JandexUtil.resolveTypeParameters(name(baseClass), name(soughtClass),
            index);
    assertThat(args).hasOnlyOneElementSatisfying(t -> {
        assertThat(t.toString()).isEqualTo(expectedArg);
    });
}
 
Example #20
Source File: IndexScannerTestBase.java    From smallrye-open-api with Apache License 2.0 5 votes vote down vote up
public static void assertJsonEquals(String expectedResource, Class<?>... classes)
        throws IOException, JSONException {
    Index index = indexOf(classes);
    OpenApiAnnotationScanner scanner = new OpenApiAnnotationScanner(nestingSupportConfig(), index);
    OpenAPI result = scanner.scan();
    printToConsole(result);
    assertJsonEquals(expectedResource, result);
}
 
Example #21
Source File: Main.java    From hibernate-demos with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    try (InputStream input = Main.class.getResourceAsStream( "/META-INF/jandex.idx" ) ) {
        IndexReader reader = new IndexReader( input );
        Index index = reader.read();

        List<AnnotationInstance> entityInstances = index.getAnnotations(
                DotName.createSimple( "com.example.a.Entity" )
        );

        for (AnnotationInstance annotationInstance : entityInstances) {
            System.out.println( annotationInstance.target().asClass().name() );
        }
    }
}
 
Example #22
Source File: PiranhaBeanArchiveHandler.java    From piranha with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public BeanArchiveBuilder handle(String beanArchiveReference) {
    
    // We're only handling the classes in the application archive, which is represented
    // by /WEB-INF/classes
    if (!"/WEB-INF/classes".equals(beanArchiveReference)) {
        return null;
    }
    
    // The beanArchiveBuilder is a builder the native archive type for Weld.
    // It roughly corresponds to a Shrinkwrap Archive builder.
    BeanArchiveBuilder beanArchiveBuilder = new BeanArchiveBuilder();
    
    // Get the class and annotation index stored into the class loader under 
    // "META-INF/piranha.idx"
    Index index = getIndex();
    
    beanArchiveBuilder.setAttribute(INDEX_ATTRIBUTE_NAME, index);
    
    // Populate the Weld Archive with all the classes from the index, representing
    // the original application archive.
    index.getKnownClasses()
         .stream()
         .map(e -> e.asClass().name().toString())
         .forEach(className -> beanArchiveBuilder.addClass(className));
    
    return beanArchiveBuilder;
}
 
Example #23
Source File: JaxRsAnnotationScannerTest.java    From smallrye-open-api with Apache License 2.0 5 votes vote down vote up
@Test
public void testTagScanning_OrderGivenAnnotations() throws IOException, JSONException {
    Index i = indexOf(TagTestApp.class, TagTestResource1.class, TagTestResource2.class);
    OpenApiAnnotationScanner scanner = new OpenApiAnnotationScanner(nestingSupportConfig(), i);
    OpenAPI result = scanner.scan();
    printToConsole(result);
    assertJsonEquals("resource.tags.ordergiven.annotation.json", result);
}
 
Example #24
Source File: JaxRsAnnotationScannerTest.java    From smallrye-open-api with Apache License 2.0 5 votes vote down vote up
@Test
public void testTagScanning() throws IOException, JSONException {
    Index i = indexOf(TagTestResource1.class, TagTestResource2.class);
    OpenApiAnnotationScanner scanner = new OpenApiAnnotationScanner(nestingSupportConfig(), i);
    OpenAPI result = scanner.scan();
    printToConsole(result);
    assertJsonEquals("resource.tags.multilocation.json", result);
}
 
Example #25
Source File: SerianalyzerState.java    From serianalyzer with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param i
 * @param ignoreNonFound
 * @param ref
 * @param retType
 * @param sigType
 * @throws SerianalyzerException
 */
public void foundImprovedReturnType ( Index i, boolean ignoreNonFound, MethodReference ref, Type retType, Type sigType )
        throws SerianalyzerException {
    MethodReference c = ref.comparable();
    this.checkedReturnType.add(c);

    if ( "java.lang.Object".equals(sigType.getClassName()) //$NON-NLS-1$
            || ( "java.io.Serializable".equals(sigType.getClassName()) && //$NON-NLS-1$
                    !"java.lang.Object".equals(retType.getClassName()) ) ) { //$NON-NLS-1$
        if ( this.returnTypes.put(c, retType) != null ) {
            this.bench.improvedReturnType();
        }
        return;
    }
    else if ( sigType.getSort() != Type.OBJECT || sigType.getClassName().endsWith("[]") ) { //$NON-NLS-1$
        return;
    }

    if ( this.returnTypes.containsKey(c) ) {
        return;
    }

    Type moreConcreteType = TypeUtil.getMoreConcreteType(i, ignoreNonFound, retType, sigType);

    if ( this.returnTypes.put(c, moreConcreteType) == null ) {
        if ( moreConcreteType.equals(retType) && !moreConcreteType.equals(sigType) ) {
            this.bench.improvedReturnType();
        }
        else {
            this.bench.nonImprovedReturnType();
        }
    }

}
 
Example #26
Source File: ResourceParameterTests.java    From smallrye-open-api with Apache License 2.0 5 votes vote down vote up
@Test
public void testGenericSetResponseWithSetUnindexed() throws IOException, JSONException {
    Index i = indexOf(FruitResource.class, Fruit.class, Seed.class);
    OpenApiAnnotationScanner scanner = new OpenApiAnnotationScanner(emptyConfig(), i);
    OpenAPI result = scanner.scan();
    printToConsole(result);
    assertJsonEquals("responses.generic-collection.set-unindexed.json", result);
}
 
Example #27
Source File: CompositeIndex.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * @see {@link Index#getKnownDirectImplementors(DotName)}
 */
public Set<ClassInfo> getKnownDirectImplementors(final DotName className) {
    final Set<ClassInfo> allKnown = new HashSet<ClassInfo>();
    for (Index index : indexes) {
        final List<ClassInfo> list = index.getKnownDirectImplementors(className);
        if (list != null) {
            allKnown.addAll(list);
        }
    }
    return Collections.unmodifiableSet(allKnown);
}
 
Example #28
Source File: ResourceParameterTests.java    From smallrye-open-api with Apache License 2.0 5 votes vote down vote up
/*************************************************************************/

    @Test
    public void testPrimitiveArrayParameter() throws IOException, JSONException {
        Index i = indexOf(PrimitiveArrayParameterTestResource.class);
        OpenApiConfig config = emptyConfig();
        IndexView filtered = new FilteredIndexView(i, config);
        OpenApiAnnotationScanner scanner = new OpenApiAnnotationScanner(config, filtered);
        OpenAPI result = scanner.scan();
        printToConsole(result);
        assertJsonEquals("resource.parameters.primitive-array-param.json", result);
    }
 
Example #29
Source File: ResourceParameterTests.java    From smallrye-open-api with Apache License 2.0 5 votes vote down vote up
@Test
public void testPrimitiveArraySchema() throws IOException, JSONException {
    Index i = indexOf(PrimitiveArraySchemaTestResource.class,
            PrimitiveArraySchemaTestResource.PrimitiveArrayTestObject.class);
    OpenApiConfig config = emptyConfig();
    IndexView filtered = new FilteredIndexView(i, config);
    OpenApiAnnotationScanner scanner = new OpenApiAnnotationScanner(config, filtered);
    OpenAPI result = scanner.scan();
    printToConsole(result);
    assertJsonEquals("resource.parameters.primitive-array-schema.json", result);
}
 
Example #30
Source File: ResourceParameterTests.java    From smallrye-open-api with Apache License 2.0 5 votes vote down vote up
@Test
public void testParameterResource() throws IOException, JSONException {
    Index i = indexOf(ParameterResource.class);
    OpenApiAnnotationScanner scanner = new OpenApiAnnotationScanner(nestingSupportConfig(), i);
    OpenAPI result = scanner.scan();
    printToConsole(result);
    assertJsonEquals("resource.parameters.simpleSchema.json", result);
}