Java Code Examples for org.eclipse.microprofile.openapi.OASFilter#filterSchema()

The following examples show how to use org.eclipse.microprofile.openapi.OASFilter#filterSchema() . 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: FilterUtil.java    From smallrye-open-api with Apache License 2.0 6 votes vote down vote up
/**
 * Filters the given model.
 * 
 * @param filter
 * @param model
 */
private static void filterSchema(OASFilter filter, Schema model) {
    if (model != null) {
        Schema ap = model.getAdditionalPropertiesSchema();
        if (ap != null) {
            filterSchema(filter, ap);
            if (filter.filterSchema(ap) == null) {
                model.setAdditionalPropertiesSchema((Schema) null);
            }
        }
        filterSchemaList(filter, model.getAllOf());
        filterSchemaList(filter, model.getAnyOf());
        filterSchema(filter, model.getItems());
        if (model.getItems() != null && filter.filterSchema(model.getItems()) == null) {
            model.setItems(null);
        }
        filterSchema(filter, model.getNot());
        if (model.getNot() != null && filter.filterSchema(model.getNot()) == null) {
            model.setNot(null);
        }
        filterSchemas(filter, model.getProperties());
    }
}
 
Example 2
Source File: FilterUtil.java    From smallrye-open-api with Apache License 2.0 5 votes vote down vote up
/**
 * Filters the given model.
 * 
 * @param filter
 * @param model
 */
private static void filterHeader(OASFilter filter, Header model) {
    if (model != null) {
        filterContent(filter, model.getContent());
        filterSchema(filter, model.getSchema());
        if (model.getSchema() != null && filter.filterSchema(model.getSchema()) == null) {
            model.setSchema(null);
        }
    }
}
 
Example 3
Source File: FilterUtil.java    From smallrye-open-api with Apache License 2.0 5 votes vote down vote up
/**
 * Filters the given model.
 * 
 * @param filter
 * @param model
 */
private static void filterMediaType(OASFilter filter, MediaType model) {
    if (model != null) {
        filterEncoding(filter, model.getEncoding());
        filterSchema(filter, model.getSchema());
        if (model.getSchema() != null && filter.filterSchema(model.getSchema()) == null) {
            model.setSchema(null);
        }
    }
}
 
Example 4
Source File: FilterUtil.java    From smallrye-open-api with Apache License 2.0 5 votes vote down vote up
/**
 * Filters the given model.
 * 
 * @param filter
 * @param model
 */
private static void filterParameter(OASFilter filter, Parameter model) {
    if (model != null) {
        filterContent(filter, model.getContent());
        filterSchema(filter, model.getSchema());
        if (model.getSchema() != null && filter.filterSchema(model.getSchema()) == null) {
            model.setSchema(null);
        }
    }
}
 
Example 5
Source File: FilterUtil.java    From smallrye-open-api with Apache License 2.0 5 votes vote down vote up
/**
 * Filters the given models.
 * 
 * @param filter
 * @param models
 */
private static void filterSchemas(OASFilter filter, Map<String, Schema> models) {
    if (models != null) {
        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);
            }
        }
    }
}
 
Example 6
Source File: FilterUtil.java    From smallrye-open-api with Apache License 2.0 5 votes vote down vote up
/**
 * Filters the given models.
 * 
 * @param filter
 * @param models
 */
private static void filterSchemaList(OASFilter filter, List<Schema> models) {
    if (models != null) {
        ListIterator<Schema> iterator = models.listIterator();
        while (iterator.hasNext()) {
            Schema model = iterator.next();
            filterSchema(filter, model);

            if (filter.filterSchema(model) == null) {
                iterator.remove();
            }
        }
    }
}