Class FileProcessor

java.lang.Object
io.micronaut.jsonschema.generator.loaders.FileProcessor

@Internal public class FileProcessor extends Object
  • Constructor Details

    • FileProcessor

      public FileProcessor()
  • Method Details

    • getJsonSchema

      public static Schema getJsonSchema(SourceGeneratorConfig config)
      Loads a JSON schema based on the configuration. This method determines the appropriate SchemaLoader based on the configuration settings and delegates the task of loading the JSON schema from the correct source (URL, file, or input stream).
      Parameters:
      config - the configuration that provides the source for the JSON schema (URL, file, or input stream)
      Returns:
      a Schema object representing the loaded JSON schema
      Throws:
      RuntimeException - if no valid source is found in the configuration or if there is an error loading the schema
    • getOutputFile

      public static File getOutputFile(Path outputPath, String packageName, String fileName) throws IOException
      Creates or retrieves a file at the specified output path, package name, and file name. The method resolves the full file path by combining the output path, the package name (which is converted to a directory structure), and the file name. It ensures that the necessary directories exist and creates the file if it doesn't already exist.

      The directories leading to the file are created if they do not exist. If the file cannot be created, an IOException is thrown.

      Parameters:
      outputPath - The base directory where the file should be created. This should be the root directory where the file structure starts.
      packageName - The package name (e.g., "com.example.project"), which will be converted to a directory path (e.g., "com/example/project").
      fileName - The name of the file to create or retrieve, including the file extension (e.g., "MyClass.java").
      Returns:
      The File object representing the output file, which will be created if it doesn't exist.
      Throws:
      IOException - If the file cannot be created, or if an I/O error occurs during file or directory creation.
    • getFileName

      public static String getFileName(Schema schema, Optional<String> topLevelName)