class SwaggerGenMojo extends AbstractMojo {

    @Override
    public void execute() throws MojoExecutionException
    {
        // Create the output directory if it doesn't already exist.
        getLog().debug("Creating output directory \"" + outputDirectory + "\".");
        java.nio.file.Path outputDirectoryPath = Paths.get(outputDirectory.toURI());
        if (!Files.exists(outputDirectoryPath))
        {
            try
            {
                Files.createDirectories(outputDirectoryPath);
            }
            catch (IOException e)
            {
                throw new MojoExecutionException("Unable to create directory for output path \"" + outputDirectoryPath + "\".", e);
            }
        }

        // Get a new Swagger metadata object.
        Swagger swagger = getSwagger();

        // Find all the model classes.
        // Note: this needs to be done before we process the REST controllers below because it finds the modelErrorClass.
        ModelClassFinder modelClassFinder = new ModelClassFinder(getLog(), modelJavaPackage, modelErrorClassName);

        // Find and process all the REST controllers and add them to the Swagger metadata.
        RestControllerProcessor restControllerProcessor =
            new RestControllerProcessor(getLog(), swagger, restJavaPackage, tagPatternParameter, modelClassFinder.getModelErrorClass());

        XsdParser xsdParser = null;
        if (xsdName != null)
        {
            xsdParser = new XsdParser(xsdName);
        }

        // Generate the definitions into Swagger based on the model classes collected.
        new DefinitionGenerator(getLog(), swagger, restControllerProcessor.getExampleClassNames(), modelClassFinder.getModelClasses(), xsdParser);

        if (applyOperationsFilter != null && applyOperationsFilter.equals(Boolean.TRUE))
        {
            OperationsFilter specFilter = new OperationsFilter(includeOperations);
            swagger = new SpecFilter().filter(swagger, specFilter, null, null, null);
        }

        // Write to Swagger information to a YAML file.
        createYamlFile(swagger);
    }

}