Search in sources :

Example 6 with Schema

use of org.eclipse.microprofile.openapi.models.media.Schema in project wildfly-swarm by wildfly-swarm.

the class FilterUtil method filterSchemas.

/**
 * Filters the given models.
 * @param filter
 * @param models
 */
private static void filterSchemas(OASFilter filter, Map<String, Schema> models) {
    if (models == null) {
        return;
    }
    Collection<String> keys = new ArrayList<>(models.keySet());
    for (String key : keys) {
        Schema model = models.get(key);
        filterSchema(filter, model);
        if (filter.filterSchema(model) == null) {
            models.remove(key);
        }
    }
}
Also used : Schema(org.eclipse.microprofile.openapi.models.media.Schema) ArrayList(java.util.ArrayList)

Example 7 with Schema

use of org.eclipse.microprofile.openapi.models.media.Schema in project wildfly-swarm by wildfly-swarm.

the class ExpectationTests method testNestedGenerics.

@Test
public void testNestedGenerics() throws IOException, JSONException {
    String name = GenericTypeTestContainer.class.getName();
    Type pType = getFieldFromKlazz(name, "nesting").type();
    OpenApiDataObjectScanner scanner = new OpenApiDataObjectScanner(index, pType);
    Schema result = scanner.process();
    printToConsole(name, result);
    assertJsonEquals(name, "generic.nested.expected.json", result);
}
Also used : Type(org.jboss.jandex.Type) ClassType(org.jboss.jandex.ClassType) Schema(org.eclipse.microprofile.openapi.models.media.Schema) Test(org.junit.Test)

Example 8 with Schema

use of org.eclipse.microprofile.openapi.models.media.Schema in project wildfly-swarm by wildfly-swarm.

the class ExpectationTests method testComplexInheritanceGenerics.

@Test
public void testComplexInheritanceGenerics() throws IOException, JSONException {
    String name = GenericTypeTestContainer.class.getName();
    Type pType = getFieldFromKlazz(name, "complexInheritance").type();
    OpenApiDataObjectScanner scanner = new OpenApiDataObjectScanner(index, pType);
    Schema result = scanner.process();
    printToConsole(name, result);
    assertJsonEquals(name, "generic.complexInheritance.expected.json", result);
}
Also used : Type(org.jboss.jandex.Type) ClassType(org.jboss.jandex.ClassType) Schema(org.eclipse.microprofile.openapi.models.media.Schema) Test(org.junit.Test)

Example 9 with Schema

use of org.eclipse.microprofile.openapi.models.media.Schema in project wildfly-swarm by wildfly-swarm.

the class ExpectationTests method testCycle.

/**
 * Unresolvable type parameter.
 */
@Test
public void testCycle() throws IOException, JSONException {
    DotName buzz = createSimple(BuzzLinkedList.class.getName());
    OpenApiDataObjectScanner scanner = new OpenApiDataObjectScanner(index, ClassType.create(buzz, Type.Kind.CLASS));
    Schema result = scanner.process();
    printToConsole(buzz.local(), result);
    assertJsonEquals(buzz.local(), "cycle.expected.json", result);
}
Also used : BuzzLinkedList(org.wildfly.swarm.microprofile.openapi.runtime.entity.BuzzLinkedList) Schema(org.eclipse.microprofile.openapi.models.media.Schema) DotName(org.jboss.jandex.DotName) Test(org.junit.Test)

Example 10 with Schema

use of org.eclipse.microprofile.openapi.models.media.Schema in project wildfly-swarm by wildfly-swarm.

the class ExpectationTests method testComplexNestedGenerics.

@Test
public void testComplexNestedGenerics() throws IOException, JSONException {
    String name = GenericTypeTestContainer.class.getName();
    Type pType = getFieldFromKlazz(name, "complexNesting").type();
    OpenApiDataObjectScanner scanner = new OpenApiDataObjectScanner(index, pType);
    Schema result = scanner.process();
    printToConsole(name, result);
    assertJsonEquals(name, "generic.complexNesting.expected.json", result);
}
Also used : Type(org.jboss.jandex.Type) ClassType(org.jboss.jandex.ClassType) Schema(org.eclipse.microprofile.openapi.models.media.Schema) Test(org.junit.Test)

Aggregations

Schema (org.eclipse.microprofile.openapi.models.media.Schema)51 Type (org.jboss.jandex.Type)15 Test (org.junit.Test)15 SchemaImpl (fish.payara.microprofile.openapi.impl.model.media.SchemaImpl)10 ClassType (org.jboss.jandex.ClassType)10 MediaType (org.eclipse.microprofile.openapi.models.media.MediaType)7 ArrayList (java.util.ArrayList)5 Parameter (org.eclipse.microprofile.openapi.models.parameters.Parameter)5 AnnotationModel (org.glassfish.hk2.classmodel.reflect.AnnotationModel)5 SchemaImpl (org.wildfly.swarm.microprofile.openapi.api.models.media.SchemaImpl)5 RequestBodyImpl (fish.payara.microprofile.openapi.impl.model.parameters.RequestBodyImpl)4 LinkedHashMap (java.util.LinkedHashMap)4 List (java.util.List)4 DMNType (org.kie.dmn.api.core.DMNType)4 Components (org.eclipse.microprofile.openapi.models.Components)3 Operation (org.eclipse.microprofile.openapi.models.Operation)3 Callback (org.eclipse.microprofile.openapi.models.callbacks.Callback)3 SchemaType (org.eclipse.microprofile.openapi.models.media.Schema.SchemaType)3 APIResponse (org.eclipse.microprofile.openapi.models.responses.APIResponse)3 APIResponses (org.eclipse.microprofile.openapi.models.responses.APIResponses)3