<commit_before>package com.englishtown.vertx.features.swagger;

import io.swagger.config.ScannerFactory;
import io.swagger.jaxrs.config.DefaultJaxrsScanner;
import io.swagger.jaxrs.listing.ApiListingResource;
import io.swagger.jaxrs.listing.SwaggerSerializers;

import javax.inject.Inject;
import javax.ws.rs.core.Feature;
import javax.ws.rs.core.FeatureContext;

/**
 * Jersey Swagger Feature
 */
public class SwaggerFeature implements Feature {

    private final SwaggerFeatureConfig config;

    @Inject
    public SwaggerFeature(SwaggerFeatureConfig config) {
        this.config = config;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public boolean configure(FeatureContext context) {

        if (config != null && !config.enabled()) {
            return false;
        }

        if (!context.getConfiguration().isRegistered(ApiListingResource.class)) {
            context.register(ApiListingResource.class);
            context.register(SwaggerSerializers.class);
        }

        if (ScannerFactory.getScanner() == null) {
            ScannerFactory.setScanner(new DefaultJaxrsScanner());
        }

        return true;
    }
}<commit_msg>Swagger - treat ApiListingResource and SwaggerSerializers as singletons.<commit_after>package com.englishtown.vertx.features.swagger;

import io.swagger.config.ScannerFactory;
import io.swagger.jaxrs.config.DefaultJaxrsScanner;
import io.swagger.jaxrs.listing.ApiListingResource;
import io.swagger.jaxrs.listing.SwaggerSerializers;

import javax.inject.Inject;
import javax.ws.rs.core.Feature;
import javax.ws.rs.core.FeatureContext;

/**
 * Jersey Swagger Feature
 */
public class SwaggerFeature implements Feature {

    private final SwaggerFeatureConfig config;

    @Inject
    public SwaggerFeature(SwaggerFeatureConfig config) {
        this.config = config;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public boolean configure(FeatureContext context) {

        if (config != null && !config.enabled()) {
            return false;
        }

        if (!context.getConfiguration().isRegistered(ApiListingResource.class)) {
            context.register(new ApiListingResource());
            context.register(new SwaggerSerializers());
        }

        if (ScannerFactory.getScanner() == null) {
            ScannerFactory.setScanner(new DefaultJaxrsScanner());
        }

        return true;
    }
}
{'fraction_non_alphanumeric': 0.10337640683618174, 'fraction_numerical': 0.0, 'mean_word_length': 3.0955631399317407, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6966613', 'n_tokens_mistral': 697, 'n_tokens_neox': 680, 'n_words': 122}